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

@megaorm/seeder

v1.0.0

Published

This package allows you to seed data into your database tables in MegaORM.

Downloads

6

Readme

MegaORM Seeder

This package allows you to seed data into your database tables in MegaORM. Each seeder file corresponds to a specific table, allowing for targeted and efficient seeding and clearing. Let's explore how to create and use seeders!

Table of Contents

  1. Installation
  2. Adding Seeder Files
  3. Seeder File Structure
  4. Seeding Tables
  5. Clearing Tables
  6. Removing Seeder Files

Installation

To install this package, run the following command:

npm install @megaorm/seeder

You should be familiar with @megaorm/cli.

Adding Seeder Files

To create a seeder file, use the following command:

node mega add:seeder <table>

To create a seeder for the users table, run:

node mega add:seeder users

This command will output the following:

Seeder added in: ./seeders/01_seed_users_table.js
  • Similar to @megaorm/gen, each seeder file is prefixed with a number, defining the order in which tables are seeded.
  • This numbering is crucial, especially when your tables reference other tables through foreign keys. Always make sure seeder files are in the same order as generator files.

Seeder File Structure

Below is an example of a seeder file for the users table:

const { MegaSeeder } = require('@megaorm/seeder');

class UsersTableSeeder extends MegaSeeder {
  constructor() {
    super();

    this.set.rows(10); // Insert 10 rows
    this.set.table('users'); // Target the 'users' table
  }

  layout() {
    const faker = this.get.faker(); // Access a MegaFaker instance

    return {
      username: faker.username(), // Generate a random username
      email: faker.email(), // Generate a random email
      password: faker.password(), // Generate a random password
      created_at: faker.datetime(), // Random datetime
      updated_at: faker.datetime(), // Random datetime
    };
  }
}

module.exports = new UsersTableSeeder(); // Export a new instance

Code Overview

  • this.set.rows(number): Defines the number of rows to create (number must be > 0).
  • this.set.table(name): Specifies the target table for seeding.
  • this.get.faker(): Accesses MegaFaker instance to generate realistic, fake data for insertion.

How it Works

  1. The layout method is executed the specified number of times to generate rows.
  2. Every time the layout method is called, it should return an object:
    • Object keys represent column names.
    • Object values represent data to insert.
  3. An INSERT SQL query is built and executed.

Seeding Tables

To seed all your tables, use:

node mega seed

To seed only one table, use:

node mega seed <table>

This command will seed the users table only:

node mega seed users

You can use this command to seed the same table multiple times!

  • The first execution inserts the specified number of rows.
  • The next execution inserts the same number of rows, and so on...

Clearing Tables

To clear all tables with associated seeder files, use:

node mega clear

To clear only one table, use the following command:

node mega clear <table>

This command will clear all data from the users table only:

node mega clear users

Removing Seeder Files

To remove a specific seeder file, use the following command:

node mega remove:seeder <table>

For example, consider the following seeders folder structure:

- 01_seed_users_table.js
- 02_seed_profiles_table.js

If you execute:

node mega remove:seeder users

The users seeder file will be removed, and the numbering will update automatically:

- 01_seed_profiles_table.js

That's it! Managing your seeder files has never been easier.