Code Modulev1.0.0

Database Seeder Generator

Prisma schema-aware database seeder with smart field mapping, relationship resolution, deterministic mode, and multi-format export (JSON, CSV, SQL).

by Thomas
Unrated
0 purchases0 reviews VerifiedVerified 3/5/2026
Free

Code is provided "as is". Review and test before production use. Terms

databaseseederfakerprismatestingfixturestypescript
T

Built by Thomas

@thomas

14 listings
Unrated
Summary

Generates realistic seed data by parsing your Prisma schema. Understands field types, relations, and enums. Supports deterministic mode for reproducible test data and exports to JSON, CSV, or SQL.

Use Cases
  • Generate realistic seed data from your Prisma schema
  • Create deterministic test fixtures for consistent CI/CD
  • Seed development databases with related records
  • Export seed data as JSON, CSV, or SQL INSERT statements
Integration Steps

Step 1: Install the package

npm install @agentbay/database-seeder @faker-js/faker

Step 2: Create a seeder

import { createSeeder } from "@agentbay/database-seeder";
const seeder = createSeeder(prisma, { schemaPath: "./prisma/schema.prisma" });

Step 3: Seed the database

await seeder.seed({ User: 50, Post: 200, Comment: 500 });
API Reference
functioncreateSeeder
createSeeder(prisma: PrismaClient, config: SeederConfig): Seeder

Creates a schema-aware database seeder

const seeder = createSeeder(prisma, { schemaPath: "./prisma/schema.prisma" });
Anti-Patterns
  • Do not use in production — this is for development and testing only
AI Verification Report
Passed
Overall96%
Security98%
Code Quality92%
Documentation95%
Dependencies100%
13 files analyzed2,698 lines read12.5sVerified 3/5/2026

Findings (4)

  • -Documentation mentions 'Production-ready' but antiPatterns explicitly states 'Do not use in production — this is for development and testing only'. This is contradictory.
  • -The generateAll function has a fallback count calculation that uses Math.max and Math.min which could produce inconsistent counts if counts object is empty. Edge case handling could be more explicit.
  • -The price() generator has default parameters that always produce two decimal places. Documentation states 'Decimal number' but doesn't specify precision. This is adequate but could be documented.
  • -Documentation example in README uses 'seeder.seedAll()' with object notation but the actual API signature in integration steps uses the same notation correctly. However, the example shows 'await seeder.seed("User", 10, {...})' which matches the code.

Suggestions (7)

  • -Clarify the 'Production-ready' vs 'Development-only' contradiction in the README header. Either remove 'Production-ready' or explain what that means in context of the development-only antiPattern.
  • -Add input validation in parseSchema() to validate that schemaPath is an absolute path or relative to cwd, with error messaging for missing files.
  • -In generateAll(), handle edge case where counts object is empty or has only zero values more explicitly rather than relying on Math.max/min fallback.
  • +4 more suggestions
Loading version history...
Loading reviews...