Open tomcastro opened 3 years ago
I have a specific use case where I need static ids, but random data. Is there a way to run DataFactory.generate, but to pass the current iteration number to the context?
For example
// school.seeder.ts public async seed() { const schools = DataFactory.createForClass(School).generate(10) }
// school.entity.ts @Factory((_, ctx) => ctx.idx) // GET CURRENT ITERATION FOR THIS CONTEXT @PrimaryGeneratedColumn() schoolId: number
I guess I could just replace them before saving them, but I was hoping there was a way of injecting this data into the current iteration context.
Or is there maybe another way I'm not contemplating? Would this be helpful as a PR?
Let me know what you think!
@tomcastro Could this help? https://github.com/edwardanthony/nestjs-seeder#userschemats-1
I have a specific use case where I need static ids, but random data. Is there a way to run DataFactory.generate, but to pass the current iteration number to the context?
For example
I guess I could just replace them before saving them, but I was hoping there was a way of injecting this data into the current iteration context.
Or is there maybe another way I'm not contemplating? Would this be helpful as a PR?
Let me know what you think!