@joakimbugge/seeder / runSeeders
Function: runSeeders()
ts
function runSeeders(seeders, options?): Promise<SeederResultMap>;Defined in: packages/seeder/src/seeder/runner.ts:147
Runs the given seeders (and all their transitive dependencies) in dependency order.
Each seeder is instantiated and its run method is called with the context derived from options. Lifecycle hooks fire at two levels:
- Class-level (
onBefore,onSuccess,onError,onFinallymethods on the seeder instance) — per-seeder logic defined directly inside the class. runSeeders-level (onBefore,onSuccess,onError,onFinallyin options) — global hooks that fire once for the entire run.
Class-level hooks fire first. Errors are re-thrown after onError and onFinally return.
Parameters
seeders
SeederCtor<unknown>[]
options?
RunSeedersOptions = {}
Returns
Promise<SeederResultMap>
Examples
ts
await runSeeders([PostSeeder], { dataSource })ts
// With console logging and a custom logger
await runSeeders([PostSeeder], {
logging: true,
logger: myLogger,
})