0
0
NextJSframework~10 mins

Prisma ORM setup in NextJS - 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.

NextJS
import { [1] } from '@prisma/client';
Drag options to blanks, or click blank then click option'
APrismaClient
BPrisma
CClient
DPrismaService
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Prisma' instead of 'PrismaClient' causes import errors.
Trying to import 'Client' alone will not work.
2fill in blank
medium

Complete the code to create a new PrismaClient instance.

NextJS
const prisma = new [1]();
Drag options to blanks, or click blank then click option'
APrisma
BClient
CPrismaClient
DPrismaService
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Prisma' instead of 'PrismaClient' causes runtime errors.
Forgetting the 'new' keyword will cause errors.
3fill in blank
hard

Fix 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'
Anew PrismaClient()
BPrismaClient()
CprismaClient
Dnew prismaClient()
Attempts:
3 left
💡 Hint
Common Mistakes
Calling PrismaClient without 'new' causes errors.
Using lowercase 'prismaClient' instead of 'PrismaClient' is incorrect.
4fill in blank
hard

Fill 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'
Auser
BfindMany
CfindFirst
Dusers
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.
5fill in blank
hard

Fill 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'
Apost
Bcreate
C`My first post`
Dupdate
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.