factory-girl
factory-girl copied to clipboard
Resetting Sequence
Hi, I have a factory that defines a property like this:
duration: Factory.sequence(function(n) { return n }),
I create multiple sets of objects
await factory.createManyAsync('object', 200 )
await factory.createManyAsync('object', 200,{ref:hardcoded_id} )
Now for the second set I like the duration sequence to start from the beginning again, how can I do that? I that possible?
Best, Stan
Solved it this way, the name of specific sequence 'createdAtSequence' can be passed in via buildOptions.
... createdAt: factory.sequence(buildOptions.createdAtSequence||'createdAt', n=> { return moment().add(parseInt((n-1)/buildOptions.per_day||100),'days').toDate() } ) ...