@joakimbugge/typeorm-seeder / SeedContext
Type Alias: SeedContext
ts
type SeedContext = BaseSeedContext & object;Defined in: packages/typeorm-seeder/src/seed/context.ts:5
Context passed through a seed operation. Available inside factory callbacks and SeederInterface.run.
Type Declaration
dataSource?
ts
optional dataSource?: DataSource;The TypeORM DataSource. Automatically set by save/saveMany calls. Also available in factory callbacks — useful for looking up existing entities instead of creating new ones:
Example
ts
@Seed(async ({ dataSource }) => dataSource.getRepository(Role).findOneByOrFail({ name: 'admin' }))
role!: Role