Skip to content

Commit

Permalink
Initial setup, setup user and post model, upsert user and create posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin committed Apr 30, 2022
1 parent c69093e commit aeeb032
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
# Keep environment variables out of version control
.env
40 changes: 40 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
// ... you will write your Prisma Client queries here
const user = await prisma.user.upsert({
where: { email: "[email protected]" },
update: {},
create: {
name: "Alice",
email: "[email protected]",
},
});

await Promise.all([
prisma.post.create({
data: { title: "TestPost1", content: "Some content 1", authorId: 99999 },
}),
prisma.post.create({
data: {
title: "TestPost2",
content: "Some content 2",
authorId: user.id,
},
}),
]);

const posts = await prisma.post.findMany();

console.dir(posts);
}

main()
.catch((e) => {
throw e;
})
.finally(async () => {
await prisma.$disconnect();
});
Loading

0 comments on commit aeeb032

Please sign in to comment.