@joakimbugge/typeorm-seeder / CreateOptions
Interface: CreateOptions<T>
Defined in: seed/creator.ts:32
Options for create and createMany on the single-class form. Extends SeedContext with a typed values override map.
Extends
Type Parameters
T
T extends EntityInstance
Properties
dataSource?
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
@Seed(async ({ dataSource }) => dataSource.getRepository(Role).findOneByOrFail({ name: 'admin' }))
role!: RoleInherited from
relations?
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
trueInherited from
values?
optional values?: SeedValues<T>;Defined in: seed/creator.ts:42
Property values to apply after all @Seed factories have run. Wins unconditionally — factories still execute but their output is overwritten. Also works for properties that have no @Seed decorator.
Example
const user = await dataSource.getRepository(User).findOneByOrFail({ name: 'Alice' })
const post = await seed(Post).create({ values: { author: user } })