Closed patran closed 4 years ago
unique
as is described in the documentation, only works with the hasMany
generator, so it has any effect on your trueFalse
field, only works on the mateIds
filed inside house
, and it ensure to have different users
inside mateIds field.
With the User's field trueFalse uniquess being true, I had expected there would be at most 2 users generated. I got 30 users. Perhaps I have misunderstood how unique works. Please share your insights. Thanks
var user = { id: { chance: 'guid' }, name: { faker: 'name.findName' }, email: { faker: 'internet.email' }, trueFalse: { faker: 'random.boolean', unique: true } }; var house = { id: { chance: 'guid' }, address: { faker: 'address.streetAddress' }, householder: { hasOne: 'users' }, mateIds: { hasMany: 'users', max: 2, min: 2, unique: true } };
mocker() .schema('users', user, 30) .schema('houses', house, 1)