Closed SerdarSanri closed 9 months ago
Should be a callback
https://lucid.adonisjs.com/docs/model-factories#relationships
export const UserFactory = Factory.define(User, ({ faker }) => {
return {
username: faker.internet.userName(),
email: faker.internet.email(),
password: faker.internet.password(),
}
})
.relation('posts', () => PostFactory) // 👈
.build()
Package version
18.4.2
Describe the bug
While creating a seeder with factory, any relationship with BelongsTo throws an exception as
this.factory is not a function
. It appears to be thrown in Factory/Relations/Base.js:47 where it tries to run factory as a function yet, factory is an object. Please see the attached screenshot below.Seeder
PatientFactory
UserFactory
PatientModel
Exception thrown at
node_modules/@adonisjs/lucid/build/src/Factory/Relations/Base.js:47
( https://github.com/adonisjs/lucid/blob/e038c67dd93b750f97240c2de98791e350c0f4bd/src/factories/relations/base.ts#L41 )Reproduction repo
No response