Files
Arian Tron 61f56f997c
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
first commit
2026-03-10 19:37:31 +03:30

154 lines
5.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { PrismaClient } from "../lib/generated/prisma-client";
const prisma = new PrismaClient();
async function main() {
// Create 5 users
await prisma.user.createMany({
data: [
{ email: "alice@example.com", name: "Alice" },
{ email: "bob@example.com", name: "Bob" },
{ email: "charlie@example.com", name: "Charlie" },
{ email: "diana@example.com", name: "Diana" },
{ email: "edward@example.com", name: "Edward" },
],
});
// Find all users to get their IDs
const userRecords = await prisma.user.findMany();
const userIdMapping = {
alice: userRecords.find((user) => user.email === "alice@example.com")?.id,
bob: userRecords.find((user) => user.email === "bob@example.com")?.id,
charlie: userRecords.find((user) => user.email === "charlie@example.com")
?.id,
diana: userRecords.find((user) => user.email === "diana@example.com")?.id,
edward: userRecords.find((user) => user.email === "edward@example.com")?.id,
};
// Create 15 posts distributed among users
await prisma.post.createMany({
data: [
// Alice's posts
{
title: "Getting Started with TypeScript and Prisma",
content:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce id erat a lorem tincidunt ultricies. Vivamus porta bibendum nulla vel accumsan.",
published: true,
authorId: userIdMapping.alice!,
},
{
title: "How ORMs Simplify Complex Queries",
content:
"Duis sagittis urna ut sapien tristique convallis. Aenean vel ligula felis. Phasellus bibendum sem at elit dictum volutpat.",
published: false,
authorId: userIdMapping.alice!,
},
// Bob's posts
{
title: "Mastering Prisma: Efficient Database Migrations",
content:
"Ut ullamcorper nec erat id auctor. Nullam nec ligula in ex feugiat tincidunt. Cras accumsan vehicula tortor ut eleifend.",
published: true,
authorId: userIdMapping.bob!,
},
{
title: "Best Practices for Type Safety in ORMs",
content:
"Aliquam erat volutpat. Suspendisse potenti. Maecenas fringilla elit vel eros laoreet, et tempor sapien vulputate.",
published: true,
authorId: userIdMapping.bob!,
},
{
title: "TypeScript Utility Types for Database Models",
content:
"Donec ac magna facilisis, vestibulum ligula at, elementum nisl. Morbi volutpat eget velit eu egestas.",
published: false,
authorId: userIdMapping.bob!,
},
// Charlie's posts (no posts for Charlie)
// Diana's posts
{
title: "Exploring Database Indexes and Their Performance Impact",
content:
"Vivamus ac velit tincidunt, sollicitudin erat quis, fringilla enim. Aenean posuere est a risus placerat suscipit.",
published: true,
authorId: userIdMapping.diana!,
},
{
title: "Choosing the Right Database for Your TypeScript Project",
content:
"Sed vel suscipit lorem. Duis et arcu consequat, sagittis justo quis, pellentesque risus. Curabitur sed consequat est.",
published: false,
authorId: userIdMapping.diana!,
},
{
title: "Designing Scalable Schemas with Prisma",
content:
"Phasellus ut erat nec elit ultricies egestas. Vestibulum rhoncus urna eget magna varius pharetra.",
published: true,
authorId: userIdMapping.diana!,
},
{
title: "Handling Relations Between Models in ORMs",
content:
"Integer luctus ac augue at tristique. Curabitur varius nisl vitae mi fringilla, vel tincidunt nunc dictum.",
published: false,
authorId: userIdMapping.diana!,
},
// Edward's posts
{
title: "Why TypeORM Still Has Its Place in 2025",
content:
"Morbi non arcu nec velit cursus feugiat sit amet sit amet mi. Etiam porttitor ligula id sem molestie, in tempor arcu bibendum.",
published: true,
authorId: userIdMapping.edward!,
},
{
title: "NoSQL vs SQL: The Definitive Guide for Developers",
content:
"Suspendisse a ligula sit amet risus ullamcorper tincidunt. Curabitur tincidunt, sapien id fringilla auctor, risus libero gravida odio, nec volutpat libero orci nec lorem.",
published: true,
authorId: userIdMapping.edward!,
},
{
title: "Optimizing Queries with Prismas Select and Include",
content:
"Proin vel diam vel nisi facilisis malesuada. Sed vitae diam nec magna mollis commodo a vitae nunc.",
published: false,
authorId: userIdMapping.edward!,
},
{
title: "PostgreSQL Optimizations Every Developer Should Know",
content:
"Nullam mollis quam sit amet lacus interdum, at suscipit libero pellentesque. Suspendisse in mi vitae magna finibus pretium.",
published: true,
authorId: userIdMapping.edward!,
},
{
title: "Scaling Applications with Partitioned Tables in PostgreSQL",
content:
"Cras vitae tortor in mauris tristique elementum non id ipsum. Nunc vitae pulvinar purus.",
published: true,
authorId: userIdMapping.edward!,
},
],
});
console.log("Seeding completed.");
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});