forked from KoalaBotUK/prisma-for-we
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (39 loc) · 1.02 KB
/
Copy pathapp.js
File metadata and controls
46 lines (39 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
});