mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 03:11:30 +03:00
Update blog db seed file.
This commit is contained in:
parent
202a8bf666
commit
087a73e97f
@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "elm-pages-example",
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
"description": "Example site built with elm-pages.",
|
||||
"scripts": {
|
||||
@ -27,5 +28,8 @@
|
||||
"dependencies": {
|
||||
"@prisma/client": "^4.9.0",
|
||||
"bcryptjs": "^2.4.3"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "node prisma/seed.js"
|
||||
}
|
||||
}
|
20
examples/blog-engine/prisma/seed.js
Normal file
20
examples/blog-engine/prisma/seed.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
[...Array(9).keys()].forEach(async (index) => {
|
||||
let slug = `${index + 1}`;
|
||||
const post = { title: slug, body: slug, slug };
|
||||
await prisma.post.upsert({
|
||||
where: { slug },
|
||||
update: post,
|
||||
create: post,
|
||||
});
|
||||
});
|
||||
|
||||
// posts.forEach(async (post) => {
|
||||
// await prisma.post.upsert({
|
||||
// where: { slug: post.slug },
|
||||
// update: post,
|
||||
// create: post,
|
||||
// });
|
||||
// });
|
@ -1,22 +0,0 @@
|
||||
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