Challenge - 5 Problems
Prisma Client Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2: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);
Attempts:
2 left
💡 Hint
Think about what Prisma returns when no record matches the query.
✗ Incorrect
Prisma Client returns null when findUnique finds no matching record.
❓ state_output
intermediate2: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);
Attempts:
2 left
💡 Hint
Prisma returns the full created record including auto-generated fields.
✗ Incorrect
The create method returns the full record including generated fields like id and createdAt.
📝 Syntax
advanced2: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'.
Attempts:
2 left
💡 Hint
Check the order and keys required by Prisma's update method.
✗ Incorrect
The update method requires where and data keys. The order of keys does not matter, but the structure must be correct.
🔧 Debug
advanced2: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);
Attempts:
2 left
💡 Hint
Consider what happens when
findUnique returns null and you try to access a property.✗ Incorrect
If findUnique returns null, accessing user.name causes a TypeError.
🧠 Conceptual
expert2: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?
Attempts:
2 left
💡 Hint
Think about the atomic nature of transactions.
✗ Incorrect
Prisma Client's $transaction ensures atomicity: if any query fails, all changes are rolled back.