From edddd32c3d2c6449d263e26952f94a4bc7d073e0 Mon Sep 17 00:00:00 2001 From: Charlie Bowe <87312031+cwsbowe@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:50:15 +0100 Subject: [PATCH 1/3] Delete app.js --- app.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 app.js diff --git a/app.js b/app.js deleted file mode 100644 index 9f02a94..0000000 --- a/app.js +++ /dev/null @@ -1,14 +0,0 @@ -const { PrismaClient } = require('@prisma/client'); -const prisma = new PrismaClient(); -// A `main` function so that you can use async/await -async function main() { - // ... you will write your Prisma Client queries here - console.log("you will write your Prisma Client queries here") -} -main() - .catch(e => { - throw e; -}) - .finally(async () => { - await prisma.$disconnect(); -}); \ No newline at end of file From 67cec6e72043b2d104904016532ea0bc9c0662fd Mon Sep 17 00:00:00 2001 From: Charlie Bowe <87312031+cwsbowe@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:54:20 +0100 Subject: [PATCH 2/3] Create app.js --- app.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/app.js @@ -0,0 +1 @@ + From 2ce346a290a4c2fde92f93d9bf230dde25d99e9d Mon Sep 17 00:00:00 2001 From: Charlie Bowe <87312031+cwsbowe@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:55:47 +0100 Subject: [PATCH 3/3] Update app.js --- app.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/app.js b/app.js index 8b13789..bd0430f 100644 --- a/app.js +++ b/app.js @@ -1 +1,46 @@ + +const { PrismaClient } = require('@prisma/client'); +const prisma = new PrismaClient(); +// A `main` function so that you can use async/await +async function main() { + // ... you will write your Prisma Client queries here + console.log("you will write your Prisma Client queries here") + // const user = await prisma.user.create({ + // data: { + // email: 'elsa@prisma.io', + // name: 'Elsa Prisma', + // }, + // }) + + const user = await prisma.user.findUnique({ + where: { + email: 'elsa@prisma.io', + }, + }) + console.log(user.name) + + const upsertUser = await prisma.user.upsert({ + where: { + email: 'viola@prisma.io', + }, + update: { + name: 'Viola the Magnificent', + }, + create: { + email: 'viola@prisma.io', + name: 'Viola the Failure', + }, + }) + + console.log(upsertUser.name) + + +} +main() + .catch(e => { + throw e; +}) + .finally(async () => { + await prisma.$disconnect(); +});