Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/02-understand-prisma/02-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Lock option (MySQL):
| Authorization and user management | Yes | Yes | No | Not yet | Not yet | Not yet |
| JSON support | Yes | No | No | Not yet | Not yet | Not yet |
| Fuzzy/Phrase Full Text Search | Yes | Yes | No | Not yet | Not yet | Not yet |
| Table inheritance | Yes | No | No | Not yet | Not yet | Yes |
| Table inheritance | Yes | No | No | Not yet | Not yet | Yes |

## Functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Data model"
metaTitle: ""
metaDescription: ""
title: 'Data model'
metaTitle: ''
metaDescription: ''
---

## Overview
Expand Down Expand Up @@ -334,7 +334,7 @@ Note that in the above case, you _must_ provide your own ID values when creating
const newUser = await prisma.user.create({
data: {
id: 1,
name: "Alice",
name: 'Alice',
},
});
```
Expand Down Expand Up @@ -397,11 +397,11 @@ Note that in this case you can only create new `Post` records by using Prisma Cl
```ts
const post = await prisma.post.create({
data: {
title: "Hello World",
title: 'Hello World',
author: {
create: {
name: "Alice",
email: "alice@prisma.io",
name: 'Alice',
email: 'alice@prisma.io',
},
},
},
Expand All @@ -413,10 +413,10 @@ Or when a `User` record with `bob@prisma.io` as its `email` already exists, you
```ts
const post = await prisma.post.create({
data: {
title: "Hello World",
title: 'Hello World',
author: {
connect: {
email: "bob@prisma.io",
email: 'bob@prisma.io',
},
},
},
Expand Down Expand Up @@ -476,8 +476,8 @@ When creating new `User` records, you now must provide a unique combination of v
```ts
const user = await prisma.user.create({
data: {
firstName: "Alice",
lastName: "Smith",
firstName: 'Alice',
lastName: 'Smith',
},
});
```
Expand All @@ -500,8 +500,8 @@ When creating new `User` records, you now must provide a unique combination of v
```ts
const user = await prisma.user.create({
data: {
firstName: "Alice",
lastName: "Smith",
firstName: 'Alice',
lastName: 'Smith',
isAdmin: true,
},
});
Expand Down Expand Up @@ -531,10 +531,10 @@ When creating new `Post` records, you now must provide a unique combination of v
```ts
const post = await prisma.post.create({
data: {
title: "Hello World",
title: 'Hello World',
author: {
connect: {
email: "alice@prisma.io",
email: 'alice@prisma.io',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,10 @@ Virtual relation fields are also present in the generated [Prisma Client API]()

```js
// Traverse relation from `Post` to `User` via fluent API
const user = await prisma.post
.findOne({ where: { id: 1 } })
.author()
const user = await prisma.post.findOne({ where: { id: 1 } }).author();

// Traverse relation from `User` to `Post` via fluent API
const user = await prisma.user
.findOne({ where: { id: 1 } })
.posts()
const user = await prisma.user.findOne({ where: { id: 1 } }).posts();
```

## The @relation attribute
Expand Down Expand Up @@ -436,12 +432,12 @@ To summarize, these are the rules for determining which side of a 1-1-relation h

Here's the summary in the form of a table assuming the two relation fields of the models from before `Profile.user` and `User.profile`:

| `Prrofile.user` | `User.profile` | Foreign key on | `@relation` attribute |
| :------------------------ | :------------------------ | ------------------------------------------------------------ | ------------------------------------------------- |
| Required | Optional | `Profile` (because the relation field on `User` is virtual) | Can't be used to determine the foreign key |
| Optional | Required | `User` (because the relation field on `Profile` is virtual) | Can't be used to determine the foreign key |
| Optional | Optional | `Profile` (because it's first in the alphabet) | Can be used to manually determine the foreign key |
| Required | Required | `Profile` (because it's first in the alphabet) | Can be used to manually determine the foreign key |
| `Prrofile.user` | `User.profile` | Foreign key on | `@relation` attribute |
| :-------------- | :------------- | ----------------------------------------------------------- | ------------------------------------------------- |
| Required | Optional | `Profile` (because the relation field on `User` is virtual) | Can't be used to determine the foreign key |
| Optional | Required | `User` (because the relation field on `Profile` is virtual) | Can't be used to determine the foreign key |
| Optional | Optional | `Profile` (because it's first in the alphabet) | Can be used to manually determine the foreign key |
| Required | Required | `Profile` (because it's first in the alphabet) | Can be used to manually determine the foreign key |

## One-to-many

Expand Down Expand Up @@ -628,7 +624,7 @@ If you're not using Prisma Migrate but obtain your data model from [introspectio
The name of the relation table must be prefixed with an underscore:

- **Valid**: `_CategoryToPost`, `_MyRelation`
- **Invalid**: ``CategoryToPost`, `MyRelation`
- **Invalid**: ``CategoryToPost`,`MyRelation`

#### Columns

Expand Down Expand Up @@ -716,7 +712,7 @@ model User {
id Int @id @default(autoincrement())
name String?
husband User? @relation("MarriagePartners")
wife User @relation("MarriagePartners", references: [id])
wife User @relation("MarriagePartners", references: [id])
}
```

Expand All @@ -731,7 +727,7 @@ model User {
id Int @id @default(autoincrement())
name String?
teacher User? @relation("TeacherStudents")
students User[] @relation("TeacherStudents")
students User[] @relation("TeacherStudents")
}
```

Expand Down Expand Up @@ -771,7 +767,7 @@ model User {
husband User? @relation("MarriagePartners")
wife User @relation("MarriagePartners")
teacher User? @relation("TeacherStudents")
students User[] @relation("TeacherStudents")
students User[] @relation("TeacherStudents")
followedBy User[] @relation("UserFollows")
following User[] @relation("UserFollows")
}
Expand Down Expand Up @@ -820,4 +816,4 @@ model Post {
author User @relation("WrittenPosts")
pinnedBy User? @relation("PinnedPost")
}
```
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Prisma schema"
metaTitle: ""
metaDescription: ""
title: 'Prisma schema'
metaTitle: ''
metaDescription: ''
---
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "CRUD"
metaTitle: ""
metaDescription: ""
title: 'CRUD'
metaTitle: ''
metaDescription: ''
---

## Overview
Expand Down Expand Up @@ -54,7 +54,7 @@ enum Role {
CRUD queries are exposed by the _model properties_ on your `PrismaClient` instance. Taking the `User` and `Post` models from above as examples, you'd invoke the CRUD queries via the `prisma.user` and `prisma.post` model properties, e.g.:

```ts
await prisma.user.create({ data: { name: "Alice" } });
await prisma.user.create({ data: { name: 'Alice' } });
// or
await prisma.post.findMany();
```
Expand Down Expand Up @@ -161,7 +161,7 @@ const result = await prisma.user.findOne({
```ts
const result = await prisma.user.findOne({
where: {
email: "alice@prisma.io",
email: 'alice@prisma.io',
},
});
```
Expand All @@ -185,8 +185,8 @@ model User {
const result = await prisma.user.findOne({
where: {
firstName_lastName: {
firstName: "Alice",
lastName: "Smith",
firstName: 'Alice',
lastName: 'Smith',
},
},
});
Expand Down Expand Up @@ -251,8 +251,8 @@ export type UserOrderByInput = {
};

export declare const OrderByArg: {
asc: "asc";
desc: "desc";
asc: 'asc';
desc: 'desc';
};
```

Expand Down Expand Up @@ -295,7 +295,7 @@ export type User = {

```ts
const user = await prisma.user.findMany({
where: { name: "Alice" },
where: { name: 'Alice' },
});
```

Expand Down Expand Up @@ -381,7 +381,7 @@ export type User = {

```ts
const user = await prisma.user.create({
data: { email: "alice@prisma.io" },
data: { email: 'alice@prisma.io' },
});
```

Expand Down Expand Up @@ -474,7 +474,7 @@ export type User = {
```ts
const user = await prisma.user.update({
where: { id: 1 },
data: { email: "alice@prisma.io" },
data: { email: 'alice@prisma.io' },
});
```

Expand Down Expand Up @@ -536,8 +536,8 @@ export type User = {
```ts
const user = await prisma.user.upsert({
where: { id: 1 },
update: { email: "alice@prisma.io" },
create: { email: "alice@prisma.io" },
update: { email: 'alice@prisma.io' },
create: { email: 'alice@prisma.io' },
});
```

Expand Down Expand Up @@ -706,8 +706,8 @@ The value of `count` is an integer and represents the number of records that hav

```ts
const updatedUserCount = await prisma.user.updateMany({
where: { name: "Alice" },
data: { name: "ALICE" },
where: { name: 'Alice' },
data: { name: 'ALICE' },
});
```

Expand Down Expand Up @@ -759,7 +759,7 @@ The value of `count` is an integer and represents the number of records that hav

```ts
const deletedUserCount = await prisma.user.deleteMany({
where: { name: "Alice" },
where: { name: 'Alice' },
});
```

Expand Down
Loading