0
0
NestJSframework~20 mins

Prisma Client usage in NestJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Prisma Client Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this Prisma Client query in NestJS?
Consider a Prisma Client query fetching a user by ID. What will be the output if the user does not exist?
NestJS
const user = await prisma.user.findUnique({ where: { id: 999 } });
console.log(user);
A{} (empty object)
Bundefined
CThrows an error
Dnull
Attempts:
2 left
💡 Hint
Think about what Prisma returns when no record matches the query.
state_output
intermediate
2:00remaining
What is the value of 'createdUser' after this Prisma create call?
Given the following Prisma Client code in a NestJS service, what does 'createdUser' contain?
NestJS
const createdUser = await prisma.user.create({
  data: { email: 'test@example.com', name: 'Test User' }
});
console.log(createdUser);
A{ email: 'test@example.com', name: 'Test User' }
B{ id: number, email: 'test@example.com', name: 'Test User', createdAt: Date }
Cnull
DThrows a runtime error
Attempts:
2 left
💡 Hint
Prisma returns the full created record including auto-generated fields.
📝 Syntax
advanced
2:00remaining
Which option correctly updates a user's name using Prisma Client in NestJS?
Select the correct Prisma Client syntax to update the name of a user with id 5 to 'Alice'.
Aawait prisma.user.update({ where: { id: 5 }, data: { name: 'Alice' } });
Bawait prisma.user.update({ data: { name: 'Alice' }, where: { id: 5 } });
Cawait prisma.user.update({ id: 5, name: 'Alice' });
Dawait prisma.user.update({ where: { id: 5 }, name: 'Alice' });
Attempts:
2 left
💡 Hint
Check the order and keys required by Prisma's update method.
🔧 Debug
advanced
2:00remaining
What error does this Prisma Client code produce?
Analyze the following code snippet and identify the error it causes.
NestJS
const user = await prisma.user.findUnique({ where: { email: 'notfound@example.com' } });
console.log(user.name);
ANo error, prints undefined
BReferenceError: user is not defined
CTypeError: Cannot read property 'name' of null
DSyntaxError: Unexpected token '.'
Attempts:
2 left
💡 Hint
Consider what happens when findUnique returns null and you try to access a property.
🧠 Conceptual
expert
2:00remaining
Which option best describes Prisma Client's transaction behavior in NestJS?
When using Prisma Client's $transaction method in NestJS, what happens if one query inside the transaction fails?
AAll queries inside the transaction are rolled back; no changes are saved.
BOnly the failed query is rolled back; others remain committed.
CThe transaction ignores errors and commits all queries anyway.
DPrisma Client throws an error but commits successful queries.
Attempts:
2 left
💡 Hint
Think about the atomic nature of transactions.