Fixes and adjustments to demo
This commit is contained in:
56
prisma/seedData.ts
Normal file
56
prisma/seedData.ts
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user