@nestjs-dash/db-seeder
v0.2.2
Published
Standalone, ORM-agnostic database seeding tool (JSON/CSV/entity/mapping input, transactional inserts, CLI) with optional adapters for TypeORM/Prisma/Drizzle/MongoDB
Readme
@nestjs-dash/db-seeder
A standalone, ORM-agnostic database seeding tool: normalizes JSON, CSV, an ORM entity/schema shape, or a plain user-defined column mapping into a common row format, then inserts it inside a real transaction. Independent of @nestjs-dash/adapter/@nestjs-dash/core — this package has no NestJS dependency and no relation to the admin-panel ResourceAdapter SPI.
Ships adapters as separate packages: @nestjs-dash/db-seeder-typeorm, @nestjs-dash/db-seeder-prisma, @nestjs-dash/db-seeder-drizzle, @nestjs-dash/db-seeder-mongodb, plus optional NestJS wiring in @nestjs-dash/db-seeder-nestjs.
Install
pnpm add @nestjs-dash/db-seeder @nestjs-dash/db-seeder-typeorm typeorm
# or the -prisma / -drizzle / -mongodb adapter instead of -typeormCLI
npx db-seeder run \
--adapter typeorm \
--connection ./dist/data-source.js \
--format csv \
--file ./seeds/authors.csv \
--mapping ./seeds/authors.mapping.json \
--on-row-error abort--dry-run normalizes the input and prints row counts without opening a connection. See db-seeder run --help for the full flag list (--entity/--model/--table for describing the seed target, --batch-size, --verbose).
Programmatic API
import { normalize, runSeeding } from '@nestjs-dash/db-seeder';
import { createAdapter } from '@nestjs-dash/db-seeder-typeorm';
const adapter = createAdapter(dataSource);
const target = { name: 'authors', columns: [{ name: 'name', required: true }] };
const rows = await normalize({ format: 'json', data: [{ name: 'Ada Lovelace' }] }, target);
await runSeeding(adapter, target, rows);Testing helpers
import { runSeederAdapterContractTests } from '@nestjs-dash/db-seeder/testing';Every adapter runs this shared behavioral suite against itself, so all four stay guaranteed-identical as they evolve — see any adapter's own adapter-contract.test.ts.
License
MIT
