Skip to main content
Version: 3.0 Alpha

Type

Types provide a way to define complex data structures that are not backed by a database table. They server two purposes:

  1. Types can be used as mixins to contain common fields and attributes shared by multiple models.
  2. Types can be used to define strongly typed JSON fields in models.

Syntax​

type NAME {
FIELD*
ATTRIBUTE*
}
  • NAME:

    Name of the model. Needs to be unique in the entire model. Must be a valid identifier.

  • FIELD:

    Arbitrary number of fields. See Field for details.

  • ATTRIBUTE:

    Arbitrary number of attributes. See Attribute for details.

Example​

type Profile {
age Int
gender String
}

type CommonFields {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model User with CommonFields {
email String @unique
name String
profile Profile? @json
}
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