Skip to content

@joakimbugge/typeorm-seeder


@joakimbugge/typeorm-seeder / SeedContext

Interface: SeedContext

Defined in: seed/registry.ts:10

Context passed through a seed operation. Available inside factory callbacks and SeederInterface.run.

Extended by

Properties

dataSource?

ts
optional dataSource?: DataSource;

Defined in: seed/registry.ts:20

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

relations?

ts
optional relations?: boolean;

Defined in: seed/registry.ts:29

Set to false to skip automatic relation seeding. Scalar and embedded properties are still seeded; only relation properties decorated with a bare @Seed() are skipped. Useful when you want to create flat entities and wire relations yourself.

Default

ts
true

Released under the MIT License.