mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-18 00:51:31 +03:00
Add prisma setup for example.
This commit is contained in:
parent
f08b0c3564
commit
2b409c6849
18
examples/blog-engine/prisma/schema.prisma
Normal file
18
examples/blog-engine/prisma/schema.prisma
Normal file
@ -0,0 +1,18 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
binaryTargets = ["native", "rhel-openssl-1.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("BLOG_DATABASE_URL")
|
||||
}
|
||||
|
||||
model Post {
|
||||
title String
|
||||
slug String @id
|
||||
body String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
22
examples/blog-engine/prisma/seed.mjs
Normal file
22
examples/blog-engine/prisma/seed.mjs
Normal file
@ -0,0 +1,22 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const posts = [
|
||||
{
|
||||
slug: "elm-pages demo",
|
||||
title: "Is elm-pages Full-Stack?",
|
||||
body: `
|
||||
# Is elm-pages Full-Stack?
|
||||
|
||||
Yes it is!
|
||||
`.trim(),
|
||||
},
|
||||
];
|
||||
|
||||
posts.forEach(async (post) => {
|
||||
await prisma.post.upsert({
|
||||
where: { slug: post.slug },
|
||||
update: post,
|
||||
create: post,
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user