Framework

Seed Remix + Prisma with Realistic Test Data

Script

// prisma/seed.ts
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

const data = await fetch("https://api.mockhero.dev/api/v1/generate", {
  method: "POST",
  headers: { "x-api-key": process.env.MOCKHERO_API_KEY!, "Content-Type": "application/json" },
  body: JSON.stringify({
    tables: [
      { name: "User", count: 20, fields: [
        { name: "id", type: "uuid" },
        { name: "email", type: "email" }
      ]},
      { name: "Note", count: 100, fields: [
        { name: "id", type: "uuid" },
        { name: "userId", type: "ref", ref: "User.id" },
        { name: "title", type: "sentence" },
        { name: "body", type: "paragraph" }
      ]}
    ]
  })
}).then(r => r.json());

await prisma.user.createMany({ data: data.User });
await prisma.note.createMany({ data: data.Note });

Wire It Up

// package.json
{ "prisma": { "seed": "tsx prisma/seed.ts" } }

Then npx prisma db seed.

Get Started

Grab your free key.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles