Skip to content
Closed
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
46 changes: 46 additions & 0 deletions apps/docs/content/docs/(index)/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Getting started
description: Choose the fastest path to start using Prisma ORM or Prisma Postgres in a new or existing project.
url: /getting-started
metaTitle: Prisma getting started
metaDescription: Choose a Prisma quickstart for new or existing projects and get from schema to first query quickly.
---

Prisma gives you a few good starting points depending on whether you need a database, already have one, or want the smallest possible local setup.

## Choose your path

### Start a new project

- [Quickstart with Prisma Postgres](/prisma-orm/quickstart/prisma-postgres) for the fastest end-to-end path with a managed PostgreSQL database
- [Quickstart with PostgreSQL](/prisma-orm/quickstart/postgresql) if you want to work with PostgreSQL
- [Quickstart with SQLite](/prisma-orm/quickstart/sqlite) for a lightweight local setup
- [Quickstart with MySQL](/prisma-orm/quickstart/mysql) if your application uses MySQL
- [Quickstart with MongoDB](/prisma-orm/quickstart/mongodb) if your application uses MongoDB

### Add Prisma to an existing project

- [Add Prisma ORM to an existing PostgreSQL project](/prisma-orm/add-to-existing-project/postgresql)
- [Add Prisma ORM to an existing MySQL project](/prisma-orm/add-to-existing-project/mysql)
- [Add Prisma ORM to an existing SQLite project](/prisma-orm/add-to-existing-project/sqlite)
- [Add Prisma ORM to an existing MongoDB project](/prisma-orm/add-to-existing-project/mongodb)
- [Add Prisma ORM to an existing Prisma Postgres project](/prisma-orm/add-to-existing-project/prisma-postgres)

## What you will do

No matter which guide you choose, the flow is usually the same:

1. Define a database connection and data model in your [Prisma schema](/orm/prisma-schema/overview).
2. Install Prisma CLI and [Prisma Client](/orm/prisma-client).
3. Run `prisma generate` to create a type-safe client for your schema.
4. Create or introspect your database, then start sending queries from your application.

## Next steps

After setup, these pages are usually the next ones people need:

- [Prisma Client overview](/orm/prisma-client)
- [Generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client)
- [Prisma Migrate getting started](/orm/prisma-migrate/getting-started)
- [Prisma schema overview](/orm/prisma-schema/overview)

1 change: 1 addition & 0 deletions apps/docs/content/docs/(index)/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"pages": [
"---Getting Started---",
"index",
"getting-started",
"---Prisma ORM---",
"...prisma-orm",
"---Prisma Postgres---",
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/accelerate/more/troubleshoot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This error may arise if images or files stored within your table are being fetch

In certain cases, a large number of records or fields are unintentionally fetched, which results in exceeding the configured query response size limit. This could happen when the [`where`](/orm/reference/prisma-client-reference#where) clause in the query is incorrect or entirely missing.

**Suggested solution:** Configure the query response size limit to be larger. If the limit is still exceeded, double-check that the `where` clause is filtering data as expected. To prevent fetching too many records, consider using [pagination](/v6/orm/prisma-client/queries/pagination). Additionally, use the [`select`](/orm/reference/prisma-client-reference#select) clause to return only the necessary fields, reducing the response size.
**Suggested solution:** Configure the query response size limit to be larger. If the limit is still exceeded, double-check that the `where` clause is filtering data as expected. To prevent fetching too many records, consider using [pagination](/orm/prisma-client/queries/pagination). Additionally, use the [`select`](/orm/reference/prisma-client-reference#select) clause to return only the necessary fields, reducing the response size.

#### Fetching a large volume of data

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/guides/upgrade-prisma-orm/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ That way, you have a single, dedicated migration that takes care of this schema

### Full-text search on PostgreSQL

The [`fullTextSearch`](/v6/orm/prisma-client/queries/full-text-search) Preview feature is promoted to General Availability only for MySQL. This means that if you're using PostgreSQL and currently make use of this Preview feature, you now need to use the new [`fullTextSearchPostgres`](/v6/orm/prisma-client/queries/full-text-search#enabling-full-text-search-for-postgresql) Preview feature:
The [`fullTextSearch`](/orm/prisma-client/queries/full-text-search) Preview feature is promoted to General Availability only for MySQL. This means that if you're using PostgreSQL and currently make use of this Preview feature, you now need to use the new [`fullTextSearchPostgres`](/orm/prisma-client/queries/full-text-search#enabling-full-text-search-for-postgresql) Preview feature:

#### Before

Expand Down Expand Up @@ -355,7 +355,7 @@ generator client {

### `fullTextSearch`

If you use the [full-text search](/v6/orm/prisma-client/queries/full-text-search) feature with **MySQL** in your app, you can now remove `fullTextSearch` from the `previewFeatures` in your Prisma schema:
If you use the [full-text search](/orm/prisma-client/queries/full-text-search) feature with **MySQL** in your app, you can now remove `fullTextSearch` from the `previewFeatures` in your Prisma schema:

```prisma
generator client {
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/orm/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metaDescription: This page gives a high-level overview of what Prisma ORM is and

Prisma ORM is [open-source](https://github.com/prisma/prisma) and consists of:

- [**Prisma Client**](/orm/prisma-client/setup-and-configuration/introduction): Auto-generated, type-safe **ORM interface**
- [**Prisma Client**](/orm/prisma-client): Auto-generated, type-safe **ORM interface**
- [**Prisma Migrate**](/orm/prisma-migrate): Database migration system
- [**Prisma Studio**](https://www.prisma.io/studio): GUI to view and edit your data

Expand Down Expand Up @@ -137,4 +137,4 @@ const user = await prisma.user.create({
## Next steps

- [**Prisma schema**](/orm/prisma-schema/overview) - Learn the schema language
- [**Prisma Client**](/orm/prisma-client/setup-and-configuration/introduction) - Explore the query API
- [**Prisma Client**](/orm/prisma-client) - Explore the query API
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const posts = await db.query.posts.findMany({

### Filtering

Drizzle exposes the underlying filter and conditional operators for a given SQL dialect. Prisma ORM on the other hand, provides a more [generic set of operators](/v6/orm/prisma-client/queries/filtering-and-sorting#combining-operators) that are intuitive to use.
Drizzle exposes the underlying filter and conditional operators for a given SQL dialect. Prisma ORM on the other hand, provides a more [generic set of operators](/orm/prisma-client/queries/filtering-and-sorting#combining-operators) that are intuitive to use.

A good example of how the filtering APIs of both Drizzle and Prisma ORM differ is by looking at `string` filters. While Drizzle provides filters for `like` and `ilike`, Prisma ORM provides more specific operators that developers can use, e.g.: `contains`, `startsWith` and `endsWith`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const posts = await Post.find({

**Prisma ORM**

Prisma ORM generates many [additional filters](/v6/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.
Prisma ORM generates many [additional filters](/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.

**Mongoose**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const post = await Post.findAll({

**Prisma ORM**

Prisma ORM generates many [additional filters](/v6/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.
Prisma ORM generates many [additional filters](/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.

**Sequelize**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following sections examine a few examples for how Prisma ORM's and TypeORM's

### Filtering

TypeORM primarily leans on SQL operators for filtering lists or records, e.g. with the `find` method. Prisma ORM on the other hand, provides a more [generic set of operators](/v6/orm/prisma-client/queries/filtering-and-sorting#combining-operators) that are intuitive to use. It should also be noted that, as explained in the type-safety section [below](#filtering-1), TypeORM loses type-safety in filter queries in many scenarios.
TypeORM primarily leans on SQL operators for filtering lists or records, e.g. with the `find` method. Prisma ORM on the other hand, provides a more [generic set of operators](/orm/prisma-client/queries/filtering-and-sorting#combining-operators) that are intuitive to use. It should also be noted that, as explained in the type-safety section [below](#filtering-1), TypeORM loses type-safety in filter queries in many scenarios.

A good example of how the filtering APIs of both TypeORM and Prisma ORM differ is by looking at `string` filters. While TypeORM primarily provides the filter based on the `ILike` operator which comes directly from SQL, Prisma ORM provides more specific operators that developers can use, e.g.: `contains`, `startsWith` and `endsWith`.

Expand Down Expand Up @@ -98,7 +98,7 @@ const posts = await postRepository.find({

### Pagination

TypeORM only offers limit-offset pagination while Prisma ORM conveniently provides dedicated APIs for both limit-offset but also cursor-based. You can learn more about both approaches in the [Pagination](/v6/orm/prisma-client/queries/pagination) section of the docs or in the API comparison [below](#pagination-1).
TypeORM only offers limit-offset pagination while Prisma ORM conveniently provides dedicated APIs for both limit-offset but also cursor-based. You can learn more about both approaches in the [Pagination](/orm/prisma-client/queries/pagination) section of the docs or in the API comparison [below](#pagination-1).

### Relations

Expand Down Expand Up @@ -781,7 +781,7 @@ const users = await userRepository.find({

**Prisma ORM**

Prisma ORM generates many [additional filters](/v6/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.
Prisma ORM generates many [additional filters](/orm/prisma-client/queries/filtering-and-sorting) that are commonly used in modern application development.

**TypeORM**

Expand Down
67 changes: 67 additions & 0 deletions apps/docs/content/docs/orm/prisma-client/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Prisma Client
description: Prisma Client is Prisma ORM's generated, type-safe query builder for Node.js, Bun, and Deno applications.
url: /orm/prisma-client
metaTitle: Prisma Client overview
metaDescription: Learn what Prisma Client is, how to generate it, and where to go next for querying, relations, and transactions.
---

Prisma Client is Prisma ORM's generated query builder. It is tailored to your schema, fully typed, and designed to make common database work feel like ordinary application code.

## What Prisma Client gives you

- Typed query methods based on your models
- Autocomplete for filters, relations, ordering, and nested writes
- Predictable plain JavaScript objects as query results
- A single client API that works across PostgreSQL, MySQL, SQLite, MongoDB, and more

## Quick start

### 1. Define a generator in your schema

```prisma title="schema.prisma"
generator client {
provider = "prisma-client"
output = "./generated"
}
```

### 2. Install Prisma Client

```npm
npm install @prisma/client
```

### 3. Generate the client

```npm
npx prisma generate
```

If you want more detail on this step, see [Generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client).

### 4. Import and use the generated client

```ts
import { PrismaClient } from "./generated/client";

const prisma = new PrismaClient();

const users = await prisma.user.findMany();
```

## Common tasks

- [Set up and configure Prisma Client](/orm/prisma-client/setup-and-configuration/introduction)
- [Generate Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client)
- [Run CRUD queries](/orm/prisma-client/queries/crud)
- [Work with relations](/orm/prisma-client/queries/relation-queries)
- [Use transactions](/orm/prisma-client/queries/transactions)
- [Use raw SQL when you need it](/orm/prisma-client/using-raw-sql)

## Related reference docs

- [Prisma Client API reference](/orm/reference/prisma-client-reference)
- [Prisma schema generators](/orm/prisma-schema/overview/generators)
- [Prisma CLI generate command](/cli/generate)

1 change: 1 addition & 0 deletions apps/docs/content/docs/orm/prisma-client/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"title": "Prisma Client",
"defaultOpen": true,
"pages": [
"index",
"setup-and-configuration",
"queries",
"client-extensions",
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/orm/prisma-client/queries/crud.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const nearbyLocations = await prisma.location.findMany({
});
```

See [Filtering and sorting](/v6/orm/prisma-client/queries/filtering-and-sorting) for more examples, or [Working with geometry fields](/orm/prisma-client/special-fields-and-types/working-with-geometry-fields) for spatial queries.
See [Filtering and sorting](/orm/prisma-client/queries/filtering-and-sorting) for more examples, or [Working with geometry fields](/orm/prisma-client/special-fields-and-types/working-with-geometry-fields) for spatial queries.

### Select fields

Expand All @@ -150,7 +150,7 @@ const users = await prisma.user.findMany({
});
```

See [Select fields](/v6/orm/prisma-client/queries/select-fields) and [Relation queries](/orm/prisma-client/queries/relation-queries) for more.
See [Select fields](/orm/prisma-client/queries/select-fields) and [Relation queries](/orm/prisma-client/queries/relation-queries) for more.

## Update

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Excluding fields
description: Learn how to exclude fields from Prisma Client results with the omit option.
url: /orm/prisma-client/queries/excluding-fields
metaTitle: Excluding fields
metaDescription: Learn how to use omit in Prisma Client to exclude fields globally or per query.
---

Use `omit` when you want Prisma Client to return the normal result shape except for a few specific fields.

## Omit a field for one query

```ts
const user = await prisma.user.findUnique({
where: { id: 1 },
omit: {
password: true,
},
});
```

## Omit fields globally

You can also configure `omit` on the client itself:

```ts
const prisma = new PrismaClient({
omit: {
user: {
password: true,
},
},
});
```

## When to use omit vs select

- Use [`select`](/orm/prisma-client/queries/select-fields) when you want to return only a small subset of fields.
- Use `omit` when the default result is mostly correct and you only want to remove a few sensitive or noisy fields.

## Related pages

- [Select fields](/orm/prisma-client/queries/select-fields)
- [Prisma Client API reference](/orm/reference/prisma-client-reference#omit)

Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Filtering and sorting
description: Learn how to filter Prisma Client queries with where and sort results with orderBy.
url: /orm/prisma-client/queries/filtering-and-sorting
metaTitle: Filtering and sorting
metaDescription: Learn how to filter Prisma Client results with where, combine operators, use relation filters, and sort with orderBy.
---

Prisma Client lets you narrow results with `where` and order them with `orderBy`.

## Filtering with where

Use `where` to match records by field values:

```ts
const users = await prisma.user.findMany({
where: {
email: {
endsWith: "prisma.io",
},
},
});
```

## Combining operators

You can compose filters with operators such as `OR`, `AND`, and `NOT`:

```ts
const users = await prisma.user.findMany({
where: {
OR: [
{ email: { endsWith: "gmail.com" } },
{ email: { endsWith: "company.com" } },
],
NOT: {
email: {
endsWith: "admin.company.com",
},
},
},
});
```

## Filter on related records

Relation filters let you match records based on related data:

```ts
const users = await prisma.user.findMany({
where: {
posts: {
some: {
published: true,
},
},
},
});
```

For more relation-specific patterns, see [Relation queries](/orm/prisma-client/queries/relation-queries).

## Sort results with orderBy

Use `orderBy` to control result ordering:

```ts
const posts = await prisma.post.findMany({
orderBy: {
title: "asc",
},
});
```

You can also combine filtering and sorting:

```ts
const posts = await prisma.post.findMany({
where: {
published: true,
},
orderBy: {
createdAt: "desc",
},
});
```

## Case-insensitive filtering

Case sensitivity depends on your database provider and collation settings. For PostgreSQL, Prisma Client also supports specific case-insensitive filter modes on supported operators. See the [Prisma Client API reference](/orm/reference/prisma-client-reference#mode) for details.

## Sort by relation

You can sort by properties on related records when the query shape supports it. For example, you might order posts by their author's name or users by related aggregates.

## Sort by relevance (PostgreSQL and MySQL)

On supported databases, Prisma Client can sort search results by relevance using `_relevance`. This is especially useful when combined with [full-text search](/orm/prisma-client/queries/full-text-search).

## Sort with null records first or last

Prisma Client supports explicit null ordering on supported databases so you can keep incomplete values grouped at the beginning or end of a result set.

## Related pages

- [Pagination](/orm/prisma-client/queries/pagination)
- [Select fields](/orm/prisma-client/queries/select-fields)
- [Prisma Client API reference](/orm/reference/prisma-client-reference#filter-conditions-and-operators)
Loading
Loading