Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Module

create

Prisma Client's create operation inserts a new database record and returns it. It supports scalar values in data and nested creation of related records.

How it works

The create operation inserts one record through a Prisma Client model delegate. Pass the values in data; Prisma returns the newly inserted record, including generated values and database defaults. A nested create can additionally insert related records while creating the parent.

Syntax

prisma.<model>.create({ data: { ... } })

Parameters

NameTypeDescription
argsCreateArgsObject containing the values for the new record and optional query arguments.

Returns

The newly created database record.

Key points

  • The create operation inserts a new record into the database.
  • A record may be created with only the fields required by the generated input type.
  • Nested creation can write a parent and related records in one operation.

Common mistakes

  • Nested creation is available for related records, but it is a distinct use of the same operation inside a parent write.

Example: Create a single record

const user = await prisma.user.create({
  data: {
    email: "alice@prisma.io",
    name: "Alice",
  },
});

Creates one User record and returns the inserted record.

When to use it

Create a single record

Insert one application entity, such as a user, with its required and optional fields.

Create related records

Insert a parent and its related records during one write.

Use returned generated values

Obtain generated identifiers and database defaults immediately after insertion.

Interview questions

QWhat does Prisma Client's create operation do?

create inserts a new database record and returns the created record. The required input is provided through the data object, which can contain scalar fields and nested relation writes.

Follow-up: How can related records be inserted in the same operation? Use a nested create inside the parent record’s relation field.

QHow do you create one User record?

Call prisma.user.create with a data object containing the new user's fields. Prisma returns the inserted user, including generated values such as an ID and database defaults.

Follow-up: What happens when a field is omitted? The operation can succeed when the schema or database supplies a generated value or default, provided all required input is otherwise present.

QWhen would you use nested create?

A nested create adds a related record or multiple related records while creating the parent. Prisma connects the nested records to the parent without requiring the caller to manually provide the relation's foreign key.

Follow-up: Why can the foreign key be omitted for nested posts? Prisma derives and fills it from the parent record created by the operation.

  • createMany
  • createManyAndReturn
  • nested create
  • data

Source: Prisma Client API (Prisma ORM v7). Checked 2026-10-16.