Fixes and adjustments to demo

This commit is contained in:
Toni Koskinen
2026-03-27 10:37:42 +02:00
parent 51a4b84476
commit 4de890ba77
44 changed files with 1076 additions and 104 deletions

56
prisma/seedData.ts Normal file
View File

@@ -0,0 +1,56 @@
import "dotenv/config";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "../libs/prisma-generated/src/client";
const connectionString = `${process.env.DATABASE_URL}`;
const adapter = new PrismaPg({ connectionString });
const prisma = new PrismaClient({ adapter });
async function main() {
const alice = await prisma.user.upsert({
where: { email: "alice@prisma.io" },
update: {},
create: {
email: "alice@prisma.io",
name: "Alice",
posts: {
create: {
title: "Check out Prisma with Next.js",
content: "https://www.prisma.io/nextjs",
published: true,
},
},
},
});
const bob = await prisma.user.upsert({
where: { email: "bob@prisma.io" },
update: {},
create: {
email: "bob@prisma.io",
name: "Bob",
posts: {
create: [
{
title: "Check out the code in gitea",
content: "https://gitea.tonssikas.ovh",
published: true,
},
{
title: "A third example card",
content: "https://google.com",
published: true,
},
],
},
},
});
console.log({ alice, bob });
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});