Skip to main content
Version: 3.0 Alpha

Create

The create series of APIs are used to create new records in the database. It has the following methods:

  • create Create a single record, optionally with nested relations.
  • createMany Create multiple records in a single operation. Nested relations are not supported. Only the number of records created is returned.
  • createManyAndReturn Similar to createMany, but returns the created records.

Samples

Click here to pop out if the embed doesn't load an interactive terminal.

Input

The create APIs accept an input object with the following fields:

  • data

    The data used to create the record. It must contain all non-optional fields of the model. It can also include nested object for creating or connecting relation entities. For create the data field must be an object. For createMany and createManyAndReturn, it can be either an object or an array of objects.

    This field is required.

  • skipDuplicates

    A boolean flag that indicates whether to skip records that would violate unique constraints. Only applicable to createMany and createManyAndReturn.

    This field is optional and defaults to false.

You can also control what fields are turned in the result using the select, include, and omit fields. Read more about field selection in the next section.

Output

The output shape of create and createManyAndReturn API is determined by the select, include, and omit fields in the input object. The output of createMany is { count: number }, giving the number of records created.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below