Closed suspiciousfellow closed 4 years ago
Yes, sorry, i didnt have time to improve the library to be 100% modular, but if you want to add a generator, basically you can start reading the src/lib/Generator.ts
there are the generators implemented, my next idea will be move the generators in separated files, but right now are there...
@danibram. Thanks for this awesome module!
I'm interested in adding a simple seed
method to the Mocker
class, here: https://github.com/danibram/mocker-data-generator/blob/master/src/lib/Mocker.ts#L17
I would specifically like to be able to seed the internal database by using this api:
mocker().seed(name, arrayOfData)
The seed
method would accept a name and an array of data, like this:
seed(name: string, data: []): Mocker {
this.DB[name] = data
return this
}
More complete example of usage:
const mocker = require('mocker-data-generator').default
const assets = require('./assets.json')
const users = require('./services/users/users.fixtures')
mocker()
.seed('assets', assets) // seeding data to be referenced by other schemas
.schema('users', users, 10)
.build()
.then(data => {
debugger
}, error => {
debugger
})
Do you foresee any issues with this API? Would you be willing to merge a pull request if I submit one?
Hi! Thanks for your comments! Yes, I have to admit that I misunderstood the issue at first, now its clear, and running in v2.8.0, sorry @suspiciousfellow You can test here Thanks! For the next one, PR always welcome, but today I was faster 😂
I think now we can close that issue
So awesome! Thank you!
so... does seed
suppose to do what it typically does in procedural generation or is it something else here? because right now it just adds the seed object as the first item in the collection and everything else is random on a runtime basis. also its not mentioned in the docs even once.
casual, faker, etc have seed options. There's not a documented way of doing that with this module. Is there one and if not if I added it and submitted a PR would you be likely to accept it?