diff --git a/examples/blog-engine/package.json b/examples/blog-engine/package.json index e35affaf..ce8346ba 100644 --- a/examples/blog-engine/package.json +++ b/examples/blog-engine/package.json @@ -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" } } \ No newline at end of file diff --git a/examples/blog-engine/prisma/seed.js b/examples/blog-engine/prisma/seed.js new file mode 100644 index 00000000..fc347698 --- /dev/null +++ b/examples/blog-engine/prisma/seed.js @@ -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, +// }); +// }); diff --git a/examples/blog-engine/prisma/seed.mjs b/examples/blog-engine/prisma/seed.mjs deleted file mode 100644 index 2de84ed4..00000000 --- a/examples/blog-engine/prisma/seed.mjs +++ /dev/null @@ -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, - }); -});