Bird
0
0

Which of the following is the correct syntax to create a new user record using Prisma in a NestJS service?

easy📝 Syntax Q12 of 15
NestJS - Database with Prisma
Which of the following is the correct syntax to create a new user record using Prisma in a NestJS service?
Athis.prisma.user.create({ data: { name: 'Alice' } })
Bthis.prisma.user.findMany({ data: { name: 'Alice' } })
Cthis.prisma.user.update({ data: { name: 'Alice' } })
Dthis.prisma.user.delete({ data: { name: 'Alice' } })
Step-by-Step Solution
Solution:
  1. Step 1: Identify the method to add a record

    The create method is used to add new records in Prisma.
  2. Step 2: Check the syntax for creating a user

    The correct syntax is this.prisma.user.create({ data: { ... } }) where data holds the new record's fields.
  3. Final Answer:

    this.prisma.user.create({ data: { name: 'Alice' } }) -> Option A
  4. Quick Check:

    Create new record = create method [OK]
Quick Trick: Use create with data object to add records [OK]
Common Mistakes:
  • Using findMany instead of create
  • Passing data to update without where clause
  • Using delete method to add records

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes