0
0
NextJSframework~10 mins

CRUD operations with Prisma in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new user with Prisma.

NextJS
const newUser = await prisma.user.[1]({ data: { name: 'Alice', email: 'alice@example.com' } });
Drag options to blanks, or click blank then click option'
Aupdate
BfindMany
Cdelete
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using findMany instead of create
Using update when creating new data
2fill in blank
medium

Complete the code to fetch all users from the database.

NextJS
const users = await prisma.user.[1]();
Drag options to blanks, or click blank then click option'
Acreate
BfindMany
Cdelete
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using create instead of findMany
Using update when fetching data
3fill in blank
hard

Fix the error in the code to update a user's email by ID.

NextJS
const updatedUser = await prisma.user.update({ where: { id: [1] }, data: { email: 'new@example.com' } });
Drag options to blanks, or click blank then click option'
A123
B'123'
Cemail
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using string ID when schema expects number
Using wrong field name for ID
4fill in blank
hard

Fill both blanks to delete a user by email.

NextJS
const deletedUser = await prisma.user.[1]({ where: { [2]: 'bob@example.com' } });
Drag options to blanks, or click blank then click option'
Adelete
Bemail
Cid
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using update instead of delete
Using id instead of email in where clause
5fill in blank
hard

Fill all three blanks to find a user by ID and update their name.

NextJS
const user = await prisma.user.[1]({ where: { [2]: [3] }, data: { name: 'Charlie' } });
Drag options to blanks, or click blank then click option'
Aupdate
Bid
C42
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using findMany instead of update
Using email instead of id
Using string instead of number for ID