ConnectDTO

This kind of DTO represents the structure of input-data to expect from 'outside' (e.g. REST API consumer) when attempting to connect to a model through a relation field.

A Models ConnectDTO class is composed of a unique'd list of isId and isUnique scalar fields. If the ConnectDTO class has exactly one property, the property is marked as required. If there are more than one property, all properties are optional (since setting a single one of them is already sufficient for a unique query) - you must however specify at least one property.

ConnectDTOs are used for relation fields in CreateDTOs and UpdateDTOs.

CreateDTO

annotations that generate corresponding input properties on CreateDTO and UpdateDTO (optional or required - depending on the nature of the relation).

When generating a Models CreateDTO class, field that meet any of the following conditions are omitted (order matters):

  • isReadOnly OR is annotated with @NoSet (Note: this apparently includes relation scalar fields)
  • field represents a relation (field.kind === 'object') and is not annotated with @RAddOnAdd or @RLnOnAdd
  • field is a relation scalar
  • field is not annotated with @OptAdd AND
    • isId && hasDefaultValue (id fields are not supposed to be provided by the user)
    • isUpdatedAt (Prisma will inject value)
    • isRequired && hasDefaultValue (for schema-required fields that fallback to a default value when empty. Think: createdAt timestamps with @default(now()) (see now()))

UpdateDTO

When generating a Models UpdateDTO class, field that meet any of the following conditions are omitted (order matters):

  • field is annotated with @OptSet
  • isReadOnly OR is annotated with @NoSet (Note: this apparently includes relation scalar fields)
  • isId (id fields are not supposed to be updated by the user)
  • field represents a relation (field.kind === 'object') and is not annotated with @RAddOnSet or @RLnOnSet
  • field is a relation scalar
  • field is not annotated with @OptSet AND
    • isId (id fields are not supposed to be updated by the user)
    • isUpdatedAt (Prisma will inject value)
    • isRequired && hasDefaultValue (for schema-required fields that fallback to a default value when empty. Think: createdAt timestamps with @default(now()) (see now()))