Skip to content

Database Seeding

Generate hundreds of related database records for development and testing with proper foreign key relationships.

Creating seed data for development requires:

  • Manual work — Writing hundreds of INSERT statements
  • Relationships — Maintaining foreign key consistency
  • Realistic data — Making it look like real production data
  • Variety — Different values, not just copy-paste
users [
template { id, role }
map (u) = {
id = u.id
uuid = "usr-" + u.id + "-" + (u.id * 1234)
email = "user" + u.id + "@example.com"
username = "user_" + u.id
role = u.role
// Profile
firstName = u.role == "admin" ? "Admin" : "User"
lastName = "Number" + u.id
avatar = "https://api.dicebear.com/7.x/avataaars/svg?seed=" + u.id
// Settings
language = u.id % 3 == 0 ? "pt" : (u.id % 3 == 1 ? "en" : "es")
theme = u.id % 2 == 0 ? "dark" : "light"
// Status
isActive = true
isVerified = u.id <= 50 ? true : false
}
// Admin users
1..5, "admin"
// Regular users
6..100, "user"
]
products [
template { id, category }
map (p) = {
id = p.id
sku = "PRD-" + p.category + "-" + p.id
name = p.category + " Product " + p.id
category = p.category
// Pricing
price = (p.id * 10) + 99
currency = "BRL"
discount = p.id % 5 == 0 ? 10 : 0
// Inventory
stock = p.id * 10
inStock = true
// SEO
slug = p.category + "-product-" + p.id
}
1..30, "electronics"
31..60, "clothing"
61..80, "books"
81..100, "home"
]
orders [
template { id, userId, productId }
map (o) = {
id = o.id
orderNumber = "ORD-2025-" + o.id
// Foreign keys
userId = o.userId
productId = o.productId
// Order details
quantity = (o.id % 5) + 1
subtotal = ((o.productId * 10) + 99) * ((o.id % 5) + 1)
// Status
status = o.id % 4 == 0 ? "delivered" : (o.id % 4 == 1 ? "shipped" : "pending")
paymentMethod = o.id % 2 == 0 ? "credit_card" : "pix"
}
// Generate 100 orders
1..25, 1, 1
26..50, 2, 5
51..75, 3, 10
76..100, 4, 15
]
// Generate 100 users
1..100, "user"
// Generate 100 products across categories
1..30, "electronics"
31..60, "clothing"
// Orders reference users and products
userId = o.userId
productId = o.productId
// Different languages
language = u.id % 3 == 0 ? "pt" : (u.id % 3 == 1 ? "en" : "es")
// Different payment methods
paymentMethod = o.id % 2 == 0 ? "credit_card" : "pix"

Realistic — Varied, production-like data
Relationships — Proper foreign keys
Scalable — Generate thousands of records
Consistent — Templates ensure structure
Fast — 100 lines → 200+ records

Perfect for:

  • Development database seeding
  • Testing with realistic data
  • Demo environments
  • Load testing data

Not ideal for:

  • Production data
  • Extremely unique records
  • Complex business logic
  1. Save to database-seed.jsson
  2. Run: jsson -i database-seed.jsson
  3. Import into your database!

Seed your database with ease! 💾