From a163fa4676ad4fa88e65055b9e181dbb18a76bf4 Mon Sep 17 00:00:00 2001
From: Jon Harrell <4829245+jharrell@users.noreply.github.com>
Date: Wed, 3 Jul 2024 09:03:25 -0500
Subject: [PATCH] fix(docs): correct relation fields documentation (#6138)
* feedback around relation fields and including fields of relations. Resolves DA-671
* fixing unrelated external links
---
.../20-data-model/20-relations/index.mdx | 55 +++----------------
.../100-queries/035-select-fields.mdx | 4 +-
.../100-queries/037-relation-queries.mdx | 4 +-
.../301-edge/550-deploy-to-deno-deploy.mdx | 8 +--
src/theme/Footer/Links/MultiColumn/index.tsx | 2 -
5 files changed, 16 insertions(+), 57 deletions(-)
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
index a859de22e0..debec24c0f 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
@@ -295,7 +295,7 @@ model Category {
-This schema is the same as the [example data model](/orm/prisma-schema/data-model/models) but has all [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields) removed (except for the required [relation scalars](/orm/prisma-schema/data-model/relations#relation-scalar-fields)) so you can focus on the [relation fields](#relation-fields).
+This schema is the same as the [example data model](/orm/prisma-schema/data-model/models) but has all [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields) removed (except for the required [relation scalar fields](/orm/prisma-schema/data-model/relations#relation-scalar-fields)) so you can focus on the [relation fields](#relation-fields).
@@ -337,7 +337,7 @@ If you're not using Prisma Migrate but obtain your data model from [introspectio
Relation [fields](/orm/prisma-schema/data-model/models#defining-fields) are fields on a Prisma [model](/orm/prisma-schema/data-model/models#defining-models) that do _not_ have a [scalar type](/orm/prisma-schema/data-model/models#scalar-fields). Instead, their type is another model.
-Every relation must have exactly two relation fields, one on each model. In the case of one-to-one and one-to-many relations, an additional _relation scalar field_ is required which gets linked by one of the two relation fields in the `@relation` attribute. This relation scalar is the direct representation of the _foreign key_ in the underlying database.
+Every relation must have exactly two relation fields, one on each model. In the case of one-to-one and one-to-many relations, an additional _relation scalar field_ is required which gets linked by one of the two relation fields in the `@relation` attribute. This relation scalar field is the direct representation of the _foreign key_ in the underlying database.
@@ -348,13 +348,13 @@ model User {
id Int @id @default(autoincrement())
email String @unique
role Role @default(USER)
- posts Post[]
+ posts Post[] // relation field (defined only at the Prisma ORM level)
}
model Post {
id Int @id @default(autoincrement())
title String
- author User @relation(fields: [authorId], references: [id])
+ author User @relation(fields: [authorId], references: [id]) // relation field (uses the relation scalar field `authorId` below)
authorId Int // relation scalar field (used in the `@relation` attribute above)
}
```
@@ -367,13 +367,13 @@ model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
role Role @default(USER)
- posts Post[]
+ posts Post[] // relation field (defined only at the Prisma ORM level)
}
model Post {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
- author User @relation(fields: [authorId], references: [id])
+ author User @relation(fields: [authorId], references: [id]) // relation field (uses the relation scalar field `authorId` below)
authorId String @db.ObjectId // relation scalar field (used in the `@relation` attribute above)
}
```
@@ -381,42 +381,9 @@ model Post {
-These models have the following fields:
-
-
-
-
-| Model | Field | Relational | Relation field |
-| :----- | :--------- | :--------- | :--------------------------- |
-| `User` | `id` | `Int` | No |
-| | `email` | `String` | No |
-| | `role` | `Role` | No |
-| | `posts` | `Post[]` | **Yes** (Prisma ORM-level) |
-| `Post` | `id` | `Int` | No |
-| | `title` | `String` | No |
-| | `authorId` | `Int` | No (_relation scalar field_) |
-| | `author` | `User` | **Yes** (_annotated_) |
-
-
-
-
-| Model | Field | Relational | Relation field | Notes |
-| :----- | :--------- | :--------- | :--------------------------- | -------------------------------------- |
-| `User` | `id` | `String` | No | Underlying database type is `ObjectId` |
-| | `email` | `String` | No |
-| | `role` | `Role` | No |
-| | `posts` | `Post[]` | **Yes** (Prisma ORM-level) |
-| `Post` | `id` | `String` | No |
-| | `title` | `String` | No |
-| | `authorId` | `String` | No (_relation scalar field_) | Underlying database type is `ObjectId` |
-| | `author` | `User` | **Yes** (_annotated_) |
-
-
-
-
Both `posts` and `author` are relation fields because their types are not scalar types but other models.
-Also note that the annotated relation field `author` needs to link the relation scalar field `authorId` on the `Post` model inside the `@relation` attribute. The relation scalar represents the foreign key in the underlying database.
+Also note that the [annotated relation field](#annotated-relation-fields) `author` needs to link the relation scalar field `authorId` on the `Post` model inside the `@relation` attribute. The relation scalar field represents the foreign key in the underlying database.
The other relation field called `posts` is defined purely on a Prisma ORM-level, it doesn't manifest in the database.
@@ -453,13 +420,7 @@ A scalar field _becomes_ a relation scalar field when it's used in the `fields`
### Relation scalar fields
-
-
-Relation scalar fields are read-only in the generated [Prisma Client API](/orm/prisma-client). If you want to update a relation in your code, you can do so using [nested writes](/orm/prisma-client/queries/relation-queries#nested-writes).
-
-
-
-#### Relation scalar naming conventions
+#### Relation scalar field naming conventions
Because a relation scalar field always _belongs_ to a relation field, the following naming convention is common:
diff --git a/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx b/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx
index dfbaf54e98..303d3e5b69 100644
--- a/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx
@@ -14,7 +14,7 @@ By default, when a query returns records (as opposed to a count), the result inc
To customize the result:
-- Use [`select`](/orm/reference/prisma-client-reference#select) to return specific fields - [you can also use a nested `select` to include relation fields](/orm/prisma-client/queries/relation-queries#select-specific-relation-fields)
+- Use [`select`](/orm/reference/prisma-client-reference#select) to return specific fields - [you can also use a nested `select` to include relation fields](/orm/prisma-client/queries/relation-queries#select-specific-fields-of-included-relations)
- Use [`include`](/orm/reference/prisma-client-reference#include) to explicitly [include relations](/orm/prisma-client/queries/relation-queries#nested-reads)
Selecting only the fields and relations that you require rather than relying on the default selection set can ✔ reduce the size of the response and ✔ improve query speed.
@@ -314,7 +314,7 @@ const users = await prisma.user.findMany({
For more information about querying relations, refer to the following documentation:
- [Include a relation (including all fields)](/orm/prisma-client/queries/relation-queries#include-all-fields-for-a-specific-relation)
-- [Select specific relation fields](/orm/prisma-client/queries/relation-queries#select-specific-relation-fields)
+- [Select specific relation fields](/orm/prisma-client/queries/relation-queries#select-specific-fields-of-included-relations)
## Relation count
diff --git a/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx b/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
index 5b704e72ea..6e69d71ce8 100644
--- a/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
@@ -241,9 +241,9 @@ const user = await prisma.user.findFirst({
-### Select specific relation fields
+### Select specific fields of included relations
-You can use a nested `select` to choose a subset of relation fields to return. For example, the following query returns the user's `name` and the `title` of each related post:
+You can use a nested `select` to choose a subset of fields of relations to return. For example, the following query returns the user's `name` and the `title` of each related post:
diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
index c44eced826..880406c0fc 100644
--- a/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
@@ -24,13 +24,13 @@ This guide demonstrates how to deploy an application to Deno Deploy in conjuncti
- a free [Deno Deploy](https://deno.com/deploy) account
- a PostgreSQL database
- Node.js & npm installed
-- Deno v1.29.4 or later installed. [Learn more](https://deno.land/manual/getting_started/installation).
+- Deno v1.29.4 or later installed. [Learn more](https://docs.deno.com/runtime/manual/#install-deno).
- (Recommended) Latest version of Prisma ORM.
-- (Recommended) Deno extension for VS Code. [Learn more](https://deno.land/manual/getting_started/setup_your_environment#visual-studio-code).
+- (Recommended) Deno extension for VS Code. [Learn more](https://docs.deno.com/runtime/manual/references/vscode_deno/).
## 1. Set up your application
-To start, you create a directory for your project, and then use `deno run` to initialize your application with `prisma init` as an [npm package with npm specifiers](https://deno.land/manual/node/npm_specifiers).
+To start, you create a directory for your project, and then use `deno run` to initialize your application with `prisma init` as an [npm package with npm specifiers](https://docs.deno.com/runtime/manual/node/npm_specifiers/).
To set up your application:
@@ -149,7 +149,7 @@ serve(handler)
**VS Code error: `An import path cannot end with a '.ts' extension`**
-If you use VS Code and see the error `An import path cannot end with a '.ts' extension` for the `import` statements at the beginning of `index.ts`, you need to install the [Deno extension for VS Code](https://deno.land/manual/getting_started/setup_your_environment#visual-studio-code), select **View** > **Command Palette** and run the command **Deno: Initialize Workspace Configuration**. This tells VS Code that the TypeScript files in the current project need to run with Deno, which then triggers the correct validations.
+If you use VS Code and see the error `An import path cannot end with a '.ts' extension` for the `import` statements at the beginning of `index.ts`, you need to install the [Deno extension for VS Code](https://docs.deno.com/runtime/manual/references/vscode_deno/), select **View** > **Command Palette** and run the command **Deno: Initialize Workspace Configuration**. This tells VS Code that the TypeScript files in the current project need to run with Deno, which then triggers the correct validations.
diff --git a/src/theme/Footer/Links/MultiColumn/index.tsx b/src/theme/Footer/Links/MultiColumn/index.tsx
index 1afe8e553f..f2fcae2d23 100644
--- a/src/theme/Footer/Links/MultiColumn/index.tsx
+++ b/src/theme/Footer/Links/MultiColumn/index.tsx
@@ -32,8 +32,6 @@ function Column({ column }: { column: ColumnType }) {
(item, i) => item?.customProps?.dropdown === "legal"
);
- console.log(column)
-
return (