Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using findMany instead of create
Using update when creating new data
✗ Incorrect
The create method is used to add a new record in Prisma.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using create instead of findMany
Using update when fetching data
✗ Incorrect
The findMany method retrieves multiple records from the database.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string ID when schema expects number
Using wrong field name for ID
✗ Incorrect
The id should be a number without quotes if the schema defines it as an integer.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using update instead of delete
Using id instead of email in where clause
✗ Incorrect
Use delete to remove a record and specify the field email in the where clause.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using findMany instead of update
Using email instead of id
Using string instead of number for ID
✗ Incorrect
Use update method, specify id as the field, and provide the numeric ID 42.