sequelize-auto-seeder
v1.2.1
Published
Generic auto data seeder for Sequelize models using Faker
Downloads
422
Maintainers
Readme
sequelize-auto-seeder
A generic, model-agnostic data seeder for Sequelize that automatically generates fake data using Faker.js.
Perfect for development, testing, or populating your database with realistic mock data.
Features
- Generate random data for any Sequelize model
- Automatically handles UUIDs, ENUMs, JSON, dates, booleans, and numbers
- Supports foreign key relationships
- Allows custom overrides for specific fields
- Works in seeders, scripts, or test setups
- Lightweight and easy to use
Installation
npm install sequelize-auto-seederUsage
Basic Example
const { autoSeed } = require("sequelize-auto-seeder");
const { User, Category, Insight } = require("./models");
(async () => {
await autoSeed(Insight, 10, {
relations: {
userId: User,
categoryId: Category,
},
});
console.log("✅ Seeder ran successfully!");
})();Overrides Example
const { autoSeed } = require("sequelize-auto-seeder");
const { Insight } = require("./models");
(async () => {
await autoSeed(Insight, 5, {
overrides: {
type: "news",
priority: () => ["top", "normal"][Math.floor(Math.random() * 2)],
metadata: () => ({
views: Math.floor(Math.random() * 1000),
tags: ["sports", "basketball"],
}),
},
});
console.log("✅ Seeder ran successfully with overrides!");
})();Relations / Foreign Keys Example
const { autoSeed } = require("sequelize-auto-seeder");
const { User, Category, Insight } = require("./models");
(async () => {
await autoSeed(Insight, 20, {
relations: {
userId: User,
categoryId: Category,
},
});
console.log("✅ Seeder ran successfully with relations!");
})();