npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ackplus/nest-seeder

v2.1.0

Published

A powerful and flexible database seeding library for NestJS applications with support for factories, data generation using Faker.js, and CLI commands

Readme

@ackplus/nest-seeder

📚 Documentation

👉 Full documentation & guides: ack-solutions.github.io/nest-seeder

| | | | --- | --- | | 🚀 Getting Started | 5-minute quickstart | | 🏭 Factories | Generate realistic data | | 🌱 Seeders | Insert & drop data | | 🖥️ CLI Reference | Every command & flag | | 📖 API Reference | Full API | | 🔀 Migration v1 → v2 | Upgrade guide | | 📝 Changelog | What changed |

✨ Features

  • 🖥️ CLI-first — run nest-seed with zero changes to your app code. Auto-detects your config.
  • 🏭 Factories + Faker.js — declare data with the @Factory decorator; supports dependent fields, inheritance, and overrides.
  • 🔄 Any ORM — TypeORM, Mongoose, Prisma, or anything Nest can inject.
  • 🎯 Selective & safe — run seeders by name, --refresh in foreign-key-safe order, or preview with --dry-run.
  • 🛠️ Scaffoldingnest-seed init generates a config, factory, and seeder.
  • 📦 Dual ESM + CJS with full TypeScript declarations.

📦 Installation

npm install @ackplus/nest-seeder @faker-js/faker
# For TypeScript config files:
npm install -D ts-node typescript

Requires Node 18+ and NestJS 10 or 11.

🚀 Quick Start

The fastest path is to scaffold the files:

npx nest-seed init

…or wire them up by hand:

1. Factorysrc/database/factories/user.factory.ts

import { Factory } from '@ackplus/nest-seeder';

export class UserFactory {
  @Factory((faker) => faker.person.firstName())
  firstName: string;

  @Factory((faker) => faker.person.lastName())
  lastName: string;

  @Factory(
    (faker, ctx) => faker.internet.email({ firstName: ctx.firstName, lastName: ctx.lastName }).toLowerCase(),
    ['firstName', 'lastName'],
  )
  email: string;

  @Factory((faker) => faker.helpers.arrayElement(['admin', 'user', 'guest']))
  role: string;
}

2. Seedersrc/database/seeders/user.seeder.ts

import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Seeder, SeederName, DataFactory } from '@ackplus/nest-seeder';
import { User } from '../entities/user.entity';
import { UserFactory } from '../factories/user.factory';

@Injectable()
@SeederName('users')
export class UserSeeder implements Seeder {
  constructor(
    @InjectRepository(User) private readonly userRepository: Repository<User>,
  ) {}

  async seed(): Promise<void> {
    const factory = DataFactory.createForClass(UserFactory);
    const users = factory.generate(10);
    await this.userRepository.save(users);
  }

  async drop(): Promise<void> {
    await this.userRepository.createQueryBuilder().delete().execute();
  }
}

3. Configseeder.config.ts (project root)

import { TypeOrmModule } from '@nestjs/typeorm';
import { defineSeederConfig } from '@ackplus/nest-seeder';
import { User } from './src/database/entities/user.entity';
import { UserSeeder } from './src/database/seeders/user.seeder';

export default defineSeederConfig({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: process.env.DB_HOST ?? 'localhost',
      port: Number(process.env.DB_PORT ?? 5432),
      username: process.env.DB_USERNAME ?? 'postgres',
      password: process.env.DB_PASSWORD ?? 'postgres',
      database: process.env.DB_DATABASE ?? 'app',
      entities: [User],
      synchronize: true,
    }),
    TypeOrmModule.forFeature([User]),
  ],
  seeders: [UserSeeder],
});

4. Run — add a script and go

{
  "scripts": {
    "seed": "nest-seed"
  }
}
npm run seed

That's it — the CLI auto-discovers seeder.config.ts and seeds your database. 🎉

🖥️ CLI at a glance

nest-seed                      # run all seeders (config auto-detected)
nest-seed --refresh            # drop (reverse order) then reseed
nest-seed --name users posts   # run only specific seeders
nest-seed --dry-run            # preview without writing
nest-seed list                 # list registered seeders
nest-seed init --orm mongoose  # scaffold starter files
nest-seed --help               # all options

See the full CLI reference.

🔀 Upgrading from v1?

v2 keeps the @Factory / Seeder / DataFactory core and modernizes the CLI, config, and packaging. Most apps upgrade in minutes — follow the Migration Guide.

🤝 Contributing

Contributions welcome! See the Contributing Guide.

📄 License

MIT © AckPlus


Built with NestJS · Powered by Faker.js