Skip to content

Commit

Permalink
fix(prisma-schema-reference): Remove duplication in @default remarks (
Browse files Browse the repository at this point in the history
  • Loading branch information
janpio authored Jun 3, 2024
1 parent 737ff28 commit fdf66f8
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions content/200-orm/500-reference/100-prisma-schema-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ Defines a single-field ID on the model.

##### Relational databases

- Corresponding database type: `PRIMARY KEY`
- Corresponding database construct: `PRIMARY KEY`
- Can be annotated with a [`@default()`](#default) value that uses [functions](#attribute-functions) to auto-generate an ID:

- [`autoincrement()`](#autoincrement)
Expand All @@ -1171,7 +1171,7 @@ Defines a single-field ID on the model.

##### MongoDB

- Corresponding database type: [Any valid BSON type, except arrays](https://docs.mongodb.com/manual/core/document/#the-_id-field)
- Corresponding database construct: [Any valid BSON type, except arrays](https://docs.mongodb.com/manual/core/document/#the-_id-field)
- Every model must define an `@id` field
- The [underlying ID field name is always `_id`](https://docs.mongodb.com/manual/core/document/#the-_id-field), and must be mapped with `@map("_id")`
- Can be defined on any scalar field (`String`, `Int`, `enum`) unless you want to use `ObjectId` in your database
Expand Down Expand Up @@ -1449,7 +1449,7 @@ Defines a multi-field ID (composite ID) on the model.

#### Remarks

- Corresponding database type: `PRIMARY KEY`
- Corresponding database construct: `PRIMARY KEY`
- Can be annotated with a [`@default()`](#default) value that uses [functions](#attribute-functions) to auto-generate an ID
- Cannot be optional
- Can be defined on any scalar field (`String`, `Int`, `enum`)
Expand Down Expand Up @@ -1587,38 +1587,33 @@ const post = await prisma.post.create({

### `@default`

Defines a [default value for a field](/orm/prisma-schema/data-model/models#defining-a-default-value) .
Defines a [default value for a field](/orm/prisma-schema/data-model/models#defining-a-default-value).

#### Remarks

- Default values that cannot yet be represented in the Prisma schema are represented by the [`dbgenerated()` function](#dbgenerated) when you use [introspection](/orm/prisma-schema/introspection).
- Default values are not allowed on relation fields in the Prisma schema. Note however that you can still define default values on the fields backing a relation (the ones listed in the `fields` argument in the `@relation` attribute). A default value on the field backing a relation will mean that relation is populated automatically for you.
- Default values can be used with [scalar lists](/orm/prisma-client/special-fields-and-types/working-with-scalar-lists-arrays) in databases that natively support them.

##### Relational databases

- Corresponding database type: `DEFAULT`
- Corresponding database construct: `DEFAULT`
- Default values can be a static value (`4`, `"hello"`) or one of the following [functions](#attribute-functions):

- [`autoincrement()`](#autoincrement)
- [`sequence()`](#sequence) (CockroachDB only)
- [`dbgenerated()`](#dbgenerated)
- [`cuid()`](#cuid)
- [`uuid()`](#uuid)
- [`now()`](#now)

- Default values that cannot yet be represented in the Prisma schema are represented by the `dbgenerated()` function when you use [introspection](/orm/prisma-schema/introspection).
- Default values are not allowed on relation fields in the Prisma schema. Note however that you can still define default values on the fields backing a relation (the ones listed in the `fields` argument in the `@relation` attribute). A default value on the field backing a relation will mean that relation is populated automatically for you.
- Default values can be used with [scalar lists](/orm/prisma-client/special-fields-and-types/working-with-scalar-lists-arrays) in databases that natively support them.

##### MongoDB

- Default values can be a static value (`4`, `"hello"`) or one of the following [functions](#attribute-functions):

- [`auto()`](#auto) (can only be used with `@db.ObjectId` to generate an `ObjectId` in MongoDB)
- [`cuid()`](#cuid)
- [`uuid()`](#uuid)
- [`now()`](#now)

- Default values are currently not allowed on relation fields in the Prisma schema.
- Default values can be used with [scalar lists](/orm/prisma-client/special-fields-and-types/working-with-scalar-lists-arrays) in databases that natively support them.

#### Arguments

| Name | Required | Type | Description |
Expand Down Expand Up @@ -1952,7 +1947,7 @@ Defines a unique constraint for this field.

##### Relational databases

- Corresponding database type: `UNIQUE`
- Corresponding database construct: `UNIQUE`
- `NULL` values are considered to be distinct (multiple rows with `NULL` values in the same column are allowed)
- Adding a unique constraint automatically adds a corresponding _unique index_ to the specified column(s).

Expand Down Expand Up @@ -2145,7 +2140,7 @@ Defines a compound [unique constraint](/orm/prisma-schema/data-model/models#defi

##### Relational databases

- Corresponding database type: `UNIQUE`
- Corresponding database construct: `UNIQUE`
- A `@@unique` block is required if it represents the only unique constraint on a model without an `@id` / `@@id`
- Adding a unique constraint automatically adds a corresponding _unique index_ to the specified column(s)

Expand Down Expand Up @@ -2382,7 +2377,7 @@ Defines an index in the database.

##### Relational databases

- Corresponding database type: `INDEX`
- Corresponding database construct: `INDEX`
- There are some additional index configuration options that cannot be provided via the Prisma schema yet. These include:
- PostgreSQL and CockroachDB:
- Define index fields as expressions (e.g. `CREATE INDEX title ON public."Post"((lower(title)) text_ops);`)
Expand Down Expand Up @@ -2505,7 +2500,7 @@ Defines meta information about the relation. [Learn more](/orm/prisma-schema/dat

##### Relational databases

- Corresponding database types: `FOREIGN KEY` / `REFERENCES`
- Corresponding database constructs: `FOREIGN KEY` / `REFERENCES`

##### MongoDB

Expand Down

0 comments on commit fdf66f8

Please sign in to comment.