Skip to content

Commit

Permalink
fix(docs): Update create vs createMany with recent changes. (#6006)
Browse files Browse the repository at this point in the history
* Update create vs createMany with recent changes. Resolves #5725

* account for custom heading ids

* install remark-custom-header-id

* escape open curly
  • Loading branch information
jharrell committed May 24, 2024
1 parent bd63db7 commit 15d41a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-all-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ jobs:
run: npm install

- name: Install remark presets
run: npm install remark-lint-no-dead-urls
run: npm install remark-lint-no-dead-urls remark-custom-header-id

- name: run remark-cli
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
npx remark-cli . -qf -e=md,mdx --use=remark-mdx --use remark-frontmatter --use remark-gfm \
npx remark-cli . -qf -e=md,mdx --use remark-mdx --use remark-custom-header-id --use remark-frontmatter --use remark-gfm \
--use "remark-lint-no-dead-urls=skipLocalhost:true,skipUrlPatterns:['https://www.notion.so/prismaio','https://www.prisma.io/docs','https://dash.cloudflare.com','https://www.cloudflare.com']"
check-for-dead-internal-links:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,14 @@ There are two ways to create or update a single record and multiple related reco
- Use a nested [`create`](/orm/reference/prisma-client-reference#create-1) query
- Use a nested [`createMany`](/orm/reference/prisma-client-reference#createmany-1) query

Each technique has pros and cons:
In most cases, a nested `create` will be preferable unless the [`skipDuplicates` query option](/orm/reference/prisma-client-reference#nested-createmany-options) is required. Here's a quick table describing the differences between the two options:

| Feature | `create` | `createMany` | Notes |
| :------------------------------------ | :------- | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Creates one record at a time | βœ” | ✘ | Potentially less performant. |
| Creates all records in one query | ✘ | βœ” | Potentially more performant. |
| Supports nesting additional relations | βœ” | ✘ \* | For example, you can create a user, several posts, and several comments per post in one query.<br />\* You can manually set a foreign key in a has-one relation - for example: `{ authorId: 9}` |
| Supports 1-n relations | βœ” | βœ” | For example, you can create a user and multiple posts (one user has many posts) |
| Supports m-n relations | βœ” | ✘ | For example, you can create a post and several categories (one post can have many categories, and one category can have many posts) |
| Supports skipping duplicate records | ✘ | βœ” | Use `skipDuplicates` query option. |
| Supports has-many relations | βœ” | βœ” | For example, you can create a user and multiple posts (one user has many posts) |
| Supports many-to-many relations | βœ” | ✘ | For example, you can create a post and several categories (one post can have many categories, and one category can have many posts) |

#### Using nested `create`

Expand Down
6 changes: 3 additions & 3 deletions content/200-orm/500-reference/050-prisma-client-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,7 @@ A nested `create` query adds a new related record or set of records to a parent
#### Remarks

- `create` is available as a nested query when you `create()` (`prisma.user.create(...)`) a new parent record or `update()` (`prisma.user.update(...)`) an existing parent record.
- You can use a nested `create` _or_ a nested [`createMany`](#createmany-1) to create multiple related records - [each technique pros and cons](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records).
- You can use a nested `create` _or_ a nested [`createMany`](#createmany-1) to create multiple related records. If you require the [`skipDuplicates` query option](#nested-createmany-options) you should use `createMany`.

#### Examples

Expand Down Expand Up @@ -2960,9 +2960,9 @@ A nested `createMany` query adds a new set of records to a parent record. See: [
- You cannot nest an additional `create` or `createMany`.
- Allows setting foreign keys directly β€” for example, setting the `categoryId` on a post.
- As of Prisma ORM version 5.12.0, nested `createMany` is supported by SQLite.
- You can use a nested `create` _or_ a nested `createMany` to create multiple related records - [each technique pros and cons](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records).
- You can use a nested `create` _or_ a nested `createMany` to create multiple related records - [if you do not need the `skipDuplicates` query option, you should probably use `create`](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records).

#### Options
#### Options \{#nested-createmany-options}

| Name | Type | Required | Description |
| ----------------- | --------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down

0 comments on commit 15d41a2

Please sign in to comment.