Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import PrismaClient from the Prisma package.
NestJS
import { [1] } from '@prisma/client';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing PrismaService instead of PrismaClient
Using a wrong or incomplete import name
✗ Incorrect
You need to import PrismaClient to interact with your database using Prisma.
2fill in blank
mediumComplete the code to create a new PrismaClient instance.
NestJS
const prisma = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using PrismaService instead of PrismaClient
Forgetting to use the 'new' keyword
✗ Incorrect
You create a new Prisma client by calling new PrismaClient().
3fill in blank
hardFix the error in the code to fetch all users from the database.
NestJS
const users = await prisma.user.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using findOne which is deprecated
Using non-existing methods like getAll or fetchAll
✗ Incorrect
To get multiple records, use findMany(). findOne() is deprecated.
4fill in blank
hardFill both blanks to create a new user with name and email.
NestJS
const newUser = await prisma.user.create({ data: { name: [1], email: [2] } }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing unquoted strings causing syntax errors
Mixing quotes and unquoted values
✗ Incorrect
Strings must be wrapped in quotes when passed as values.
5fill in blank
hardFill all three blanks to update a user's email by id.
NestJS
const updatedUser = await prisma.user.update({ where: { id: [1] }, data: { email: [2] }, select: { [3]: true } }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numeric id
Not quoting the email string
Missing the select field name
✗ Incorrect
The id is a number without quotes, email is a string with quotes, and select specifies the field to return.