@joakimbugge/typeorm-seeder / SaveManyOptions
Interface: SaveManyOptions<T>
Defined in: seed/persist.ts:30
Options for saveMany. Extends SaveOptions with a required instance count.
Extends
SaveOptions<T>
Type Parameters
T
T extends EntityInstance = EntityInstance
Properties
count
count: number;Defined in: seed/persist.ts:31
dataSource
dataSource: DataSource;Defined in: seed/persist.ts:14
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/persist.ts:26
Property values to apply to each entity after seeding and before persisting. Wins unconditionally over @Seed factory output — the factory still runs, but its result is overwritten. Also works for properties that have no @Seed decorator at all.
Example
const users = await dataSource.getRepository(User).find()
const user = faker.helpers.arrayElement(users)
await seed(Booking).saveMany(10, { dataSource, values: { user } })