Skip to content

@joakimbugge/typeorm-seeder


@joakimbugge/typeorm-seeder / SaveManyOptions

Interface: SaveManyOptions<T>

Defined in: seed/persist.ts:30

Options for saveMany. Extends SaveOptions with a required instance count.

Extends

Type Parameters

T

T extends EntityInstance = EntityInstance

Properties

count

ts
count: number;

Defined in: seed/persist.ts:31


dataSource

ts
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

ts
@Seed(async ({ dataSource }) => dataSource.getRepository(Role).findOneByOrFail({ name: 'admin' }))
role!: Role

Inherited from

SaveOptions.dataSource


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

Inherited from

SaveOptions.relations


values?

ts
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

ts
const users = await dataSource.getRepository(User).find()
const user = faker.helpers.arrayElement(users)
await seed(Booking).saveMany(10, { dataSource, values: { user } })

Inherited from

SaveOptions.values

Released under the MIT License.