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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'Is Prisma an ORM?'
metaTitle: 'Is Prisma an ORM?'
metaDescription: "Learn why Prisma is not an ORM. It shares similar goals with ORMs and wants to make working with databases easy, but it does not map classes to tables as ORMs do."
metaDescription: 'Learn why Prisma is not an ORM. It shares similar goals with ORMs and wants to make working with databases easy, but it does not map classes to tables as ORMs do.'
---

## Overview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ The following tables list all supported operating systems with the name of the b

#### Linux (Ubuntu)

| Build OS | Build name | OpenSSL |
| :-------------------- | :--------------------- | :------: |
| Ubuntu 14.04 (trusty) | `debian-openssl-1.0.x` | 1.0.x |
| Ubuntu 16.04 (xenial) | `debian-openssl-1.0.x` | 1.0.x |
| Ubuntu 18.04 (bionic) | `debian-openssl-1.1.x` | 1.1.x |
| Ubuntu 19.04 (disco) | `debian-openssl-1.1.x` | 1.1.x |
| Build OS | Build name | OpenSSL |
| :-------------------- | :--------------------- | :-----: |
| Ubuntu 14.04 (trusty) | `debian-openssl-1.0.x` | 1.0.x |
| Ubuntu 16.04 (xenial) | `debian-openssl-1.0.x` | 1.0.x |
| Ubuntu 18.04 (bionic) | `debian-openssl-1.1.x` | 1.1.x |
| Ubuntu 19.04 (disco) | `debian-openssl-1.1.x` | 1.1.x |

#### Linux (CentOS)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Here's an overview of these for the fields from the `User` model [above](#exampl

### Naming fields

Field names _must_ start with a letter and are typically spelled in [camelCase](http://wiki.c2.com/?CamelCase).
Field names _must_ start with a letter and are typically spelled in [camelCase](http://wiki.c2.com/?CamelCase).

Technically, a field can be named anything that adheres to this regular expression:

Expand Down Expand Up @@ -192,7 +192,7 @@ const allUsers = await prisma.user.findMany();

Prisma Client not only provides a query API for models, it also generates type definitions that reflect your model structures. These are part of the generated [`@prisma/client`](../prisma-client/generating-prisma-client#the-prisma-client-npm-module) node module in a file called `index.d.ts`.

When using TypeScript, these type definitions ensure that all your database queries are entirely type safe and validated at compile-time (even partial queries using [`select`](../prisma-client/field-selection#select) or [`include`](../prisma-client/field-selection#include)).
When using TypeScript, these type definitions ensure that all your database queries are entirely type safe and validated at compile-time (even partial queries using [`select`](../prisma-client/field-selection#select) or [`include`](../prisma-client/field-selection#include)).

Even when using plain JavaScript, the type definitions are still included in the generated `@prisma/client` node module, enabling features like [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)/autocompletion in your editor.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ Once you instantiated `PrismaClient`, you can start sending queries in your code
```ts
// run inside `async` function
const newUser = await prisma.user.create({
data: {
name: "Alice",
email: "alice@prisma.io"
}
})
const users = await prisma.user.findMany()
data: {
name: 'Alice',
email: 'alice@prisma.io',
},
});
const users = await prisma.user.findMany();
```

### 4. Evolving your application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ This query returns all `Post` records by a specific `User`:
```ts
const postsByUser: Post[] = await prisma.user
.findOne({ where: { email: 'alice@prisma.io' } })
.posts()
.posts();
```

Note that this call is equivalent to this Prisma Client query:

```ts
const postsByUser = await prisma.post.findMany({
where: { author: { email: 'alice@prisma.io' } },
})
});
```

The main difference between the two is that the fluent API call is translated into two separate database queries while the other one only generates a single query (see this [GitHub issue](https://github.com/prisma/prisma2/issues/1984)).

This request returns all categories by a specific post:

```ts
const categoriesOfPost: Category[] = await prisma.post.findOne({ where: { id: 1 } }).categories()
const categoriesOfPost: Category[] = await prisma.post.findOne({ where: { id: 1 } }).categories();
```

Note that you can chain as many queries as you like. In this example, the chanining starts at `Profile` and goes over `User` to `Post`:
Expand Down Expand Up @@ -119,7 +119,7 @@ const posts: Post[] = await prisma.user
where: {
title: { startsWith: 'Hello' },
},
})
});
```

Note that this query is _equivalent_ to the following one which is initiated via the `post` instead of the `user` field (i.e. it doesn't use the fluent API):
Expand All @@ -130,8 +130,8 @@ const posts = await prisma.post.findMany({
author: { email: 'bob@prisma.io' },
title: { startsWith: 'Hello' },
},
})
console.log(posts)
});
console.log(posts);
```

The main difference between the two is that the fluent API call is translated into two separate database queries while the other one only generates a single query (see this [GitHub issue](https://github.com/prisma/prisma2/issues/1984)).
Expand Down Expand Up @@ -187,7 +187,7 @@ const user = await prisma.user.create({
create: { bio: 'Hello World' },
},
},
})
});
```

This example uses the `user` model property, but you could also run the query from the `profile` side:
Expand All @@ -200,7 +200,7 @@ const user = await prisma.profile.create({
create: { email: 'alice@prisma.io' },
},
},
})
});
```

**Create a new `Profile` record and connect it to an existing `User` record**
Expand All @@ -213,7 +213,7 @@ const user = await prisma.profile.create({
connect: { email: 'alice@prisma.io' },
},
},
})
});
```

Note that this requires that a `User` record with an `email` of `"alice@prisma.io"` already exists in the database. If that's not the case, the query will fail with an exception.
Expand All @@ -228,7 +228,7 @@ const user = await prisma.profile.create({
connect: { id: 42 },
},
},
})
});
```

**Update an existing `User` record by creating a new `Profile` record**
Expand All @@ -241,7 +241,7 @@ const user = await prisma.user.update({
create: { bio: 'Hello World' },
},
},
})
});
```

**Update an existing `User` record by connecting it to an existing `Profile` record**
Expand All @@ -254,7 +254,7 @@ const user = await prisma.user.update({
connect: { id: 24 },
},
},
})
});
```

**Update an existing `User` record by updating the `Profile` record it's connected to**
Expand All @@ -267,7 +267,7 @@ const user = await prisma.user.update({
update: { bio: 'Hello World' },
},
},
})
});
```

**Update an existing `User` record by updating the `Profile` record it's connected to or creating a new one (_upsert_)**
Expand All @@ -283,7 +283,7 @@ const user = await prisma.user.update({
},
},
},
})
});
```

**Update an existing `User` record by deleting the `Profile` record it's connected to**
Expand All @@ -296,7 +296,7 @@ const user = await prisma.user.update({
delete: true,
},
},
})
});
```

**Update an existing `User` record by disconnecting the `Profile` record it's connected to**
Expand All @@ -309,7 +309,7 @@ const user = await prisma.user.update({
disconnect: true,
},
},
})
});
```

Note that this query is actually illegal with the data model from above because the `user` field on `Profile` is required. In order to make this query succeed, you'd need to make both relation fields optional:
Expand Down Expand Up @@ -372,7 +372,7 @@ const user = await prisma.user.create({
create: { title: 'Hello World' },
},
},
})
});
```

This example uses the `user` model property, but you could also run the query from the `post` side:
Expand All @@ -385,7 +385,7 @@ const user = await prisma.post.create({
create: { email: 'alice@prisma.io' },
},
},
})
});
```

**Create a new `User` record with two new `Post` records**:
Expand All @@ -400,7 +400,7 @@ const user = await prisma.user.create({
create: [{ title: 'This is my first post' }, { title: 'Here comes a second post' }],
},
},
})
});
```

**Create a new `Post` record and connect it to an existing `User` record**
Expand All @@ -413,7 +413,7 @@ const user = await prisma.post.create({
connect: { email: 'alice@prisma.io' },
},
},
})
});
```

Note that this requires that a `User` record with an `email` of `"alice@prisma.io"` already exists in the database. If that's not the case, the query will fail with an exception.
Expand All @@ -428,7 +428,7 @@ const user = await prisma.post.create({
connect: { id: 42 },
},
},
})
});
```

**Update an existing `User` record by creating a new `Post` record**
Expand All @@ -441,7 +441,7 @@ const user = await prisma.user.update({
create: { title: 'Hello World' },
},
},
})
});
```

**Update an existing `User` record by connecting it to two existing `Post` records**
Expand All @@ -454,7 +454,7 @@ const user = await prisma.user.update({
connect: [{ id: 24 }, { id: 42 }],
},
},
})
});
```

**Update an existing `User` record by updating two `Post` records it's connected to**
Expand All @@ -476,7 +476,7 @@ const user = await prisma.user.update({
],
},
},
})
});
```

**Update an existing `User` record by updating two `Post` record it's connected to or creating new ones (_upsert_)**
Expand All @@ -500,7 +500,7 @@ const user = await prisma.user.update({
],
},
},
})
});
```

**Update an existing `User` record by deleting two `Post` records it's connected to**
Expand All @@ -513,7 +513,7 @@ const user = await prisma.user.update({
delete: [{ id: 34 }, { id: 36 }],
},
},
})
});
```

**Update an existing `User` record by disconnecting two `Post` records it's connected to**
Expand All @@ -526,7 +526,7 @@ const user = await prisma.user.update({
disconnect: [{ id: 44 }, { id: 46 }],
},
},
})
});
```

**Update an existing `User` record by disconnecting any previous `Post` records and connect two other exiting ones**
Expand All @@ -539,7 +539,7 @@ const user = await prisma.user.update({
set: [{ id: 32 }, { id: 42 }],
},
},
})
});
```

## Nested reads
Expand All @@ -556,7 +556,7 @@ const users = await prisma.user.findMany({
posts: true,
profile: true,
},
})
});
```

**Include the `posts` relation on the returned objects when creating a new `User` record with two `Post` records**
Expand All @@ -570,7 +570,7 @@ const user = await prisma.user.create({
},
},
include: { posts: true },
})
});
```

**Retrieve deeply nested data by loading several levels of relations**
Expand All @@ -588,5 +588,5 @@ const users = await prisma.user.findMany({
},
},
},
})
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Consider the following example `findOne` invocation:
```ts
const result = await prisma.user.findOne({
where: { id: 1 },
})
});
```

The `result` of this API call is a plain old JavaScript object that might look similar to this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metaDescription: ''

The Prisma CLI is available as an [npm package](). It is **recommended to install the Prisma CLI locally** in your project's `package.json` to avoid version conflicts.


### Local installation (recommended)

The Prisma CLI is typically installed as a **development dependency**, that's why the `--save-dev` (npm) and `--dev` (Yarn) options are used in the commands below.
Expand Down
Loading