Framework

Seed Nuxt + PlanetScale with MockHero

The Setup

Nuxt 3 + Nitro + Prisma + PlanetScale. PlanetScale doesn't support foreign keys in MySQL, but you can still model relations via ref fields in MockHero and enforce them in app code.

// scripts/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: 40, fields: [
        { name: "id", type: "uuid" },
        { name: "email", type: "email" }
      ]},
      { name: "Event", count: 160, fields: [
        { name: "id", type: "uuid" },
        { name: "userId", type: "ref", ref: "User.id" },
        { name: "name", type: "sentence" }
      ]}
    ]
  })
}).then(r => r.json());

await prisma.user.createMany({ data: data.User });
await prisma.event.createMany({ data: data.Event });

Get Started

Free API 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