0
0
NestJSframework~10 mins

Prisma Client usage in NestJS - Interactive Code Practice

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

Complete 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'
APrismaClient
BPrismaService
CClient
DPrisma
Attempts:
3 left
💡 Hint
Common Mistakes
Importing PrismaService instead of PrismaClient
Using a wrong or incomplete import name
2fill in blank
medium

Complete the code to create a new PrismaClient instance.

NestJS
const prisma = new [1]();
Drag options to blanks, or click blank then click option'
APrismaService
BPrisma
CClient
DPrismaClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using PrismaService instead of PrismaClient
Forgetting to use the 'new' keyword
3fill in blank
hard

Fix 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'
AfetchAll
BfindOne
CfindMany
DgetAll
Attempts:
3 left
💡 Hint
Common Mistakes
Using findOne which is deprecated
Using non-existing methods like getAll or fetchAll
4fill in blank
hard

Fill 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'
A"Alice"
B"alice@example.com"
CAlice
Dalice@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Passing unquoted strings causing syntax errors
Mixing quotes and unquoted values
5fill in blank
hard

Fill 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'
A42
B"newemail@example.com"
Cemail
D"42"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numeric id
Not quoting the email string
Missing the select field name