Skip to content

Commit

Permalink
fix(relation-queries): Clarify and fix create vs createMany
Browse files Browse the repository at this point in the history
  • Loading branch information
janpio authored Mar 15, 2024
1 parent 46f9238 commit 1885974
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,15 @@ Each technique has pros and cons:
| 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) |

The following query uses nested [`create`](/orm/reference/prisma-client-reference#create) to create:
#### Using nested `create`

The following query uses nested [`create`](/orm/reference/prisma-client-reference#create-1) to create:

- One user
- Two posts
- One post category

The example uses a nested `include` to include all posts and post categories.
The example also uses a nested `include` to include all posts and post categories in the returned data.

<CodeWithResult outputResultText="query">
<cmd>
Expand Down Expand Up @@ -628,12 +630,14 @@ const result = await prisma.user.create({
</cmdResult>
</CodeWithResult>

The following query uses a nested [`createMany`](/orm/reference/prisma-client-reference#create) to create:
#### Using nested `createMany`

The following query uses a nested [`createMany`](/orm/reference/prisma-client-reference#create-1) to create:

- One user
- Two posts

The example uses a nested `include` to include all posts.
The example also uses a nested `include` to include all posts in the returned data.

<CodeWithResult outputResultText="query">
<cmd>
Expand Down

0 comments on commit 1885974

Please sign in to comment.