We can generate a single entity using the factory and blueprints we defined.
await entityFactory
.for('user') // get builder instance for 'user'
.make() // generate a user without id
Use the factory make multple posts.
By using "make" we can generate them without incrementing ids
await entityFactory
.for('post') // get builder instance for 'user'
.make(3) // generate 3 posts without id's
If "create" is called, the adapter will "persist" them which in the case of the object adapter means that it will generate id's.
// Create users with embedded posts
await entityFactory
.for('user') // get builder instance for 'user'
.create(3) // generate 3 users with incrementing id's
Entities can also be generated with varying states. In this case lets use the 'with-posts' state for users to get a user with embedded posts.
// Create users with embedded posts
await entityFactory
.for('user') // get builder instance for 'user'
.state('with-posts') // use 'with-posts' state transform
.create() // generate user with incrementing id's
There are times as well when a blueprint may not be required but and we simply want to generate random one-off data. This can be accomplished using the "gen" method.