Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import PrismaClient from the Prisma package.
NextJS
import { [1] } from '@prisma/client';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Prisma' instead of 'PrismaClient' causes import errors.
Trying to import 'Client' alone will not work.
✗ 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.
NextJS
const prisma = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Prisma' instead of 'PrismaClient' causes runtime errors.
Forgetting the 'new' keyword will cause errors.
✗ Incorrect
You create a new instance of PrismaClient to start querying your database.
3fill in blank
hardFix the error in the code to correctly export the Prisma client instance.
NextJS
export const prisma = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling PrismaClient without 'new' causes errors.
Using lowercase 'prismaClient' instead of 'PrismaClient' is incorrect.
✗ Incorrect
You must export the instance created with new PrismaClient() to use it elsewhere.
4fill in blank
hardFill both blanks to write a Prisma query that fetches all users.
NextJS
const users = await prisma.[1].[2]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'users' instead of 'user' for the model name causes errors.
Using 'findFirst' returns only one record, not all.
✗ Incorrect
Use prisma.user.findMany() to get all user records from the database.
5fill in blank
hardFill all three blanks to write a Prisma query that creates a new post with a title.
NextJS
const newPost = await prisma.[1].[2]({ data: { title: [3] } });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' instead of 'create' will not add a new record.
Forgetting to wrap the title string in quotes or backticks causes syntax errors.
✗ Incorrect
Use prisma.post.create() with a data object to add a new post. The title is a string wrapped in backticks.