Skip to content

Commit

Permalink
Merge branch 'main' into longrunning-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell authored Jan 9, 2025
2 parents ee261d7 + cfa887b commit 40feaae
Show file tree
Hide file tree
Showing 100 changed files with 3,766 additions and 5,680 deletions.
5 changes: 4 additions & 1 deletion cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"Aiven",
"Ania",
"Koyeb",
"Inngest",
"Neward",
"nikolasburk",
"Slonik",
Expand All @@ -111,7 +112,9 @@
"Hyperdrive",
"pgcat",
"JAFNSZHQRDTW",
"BCAA"
"BCAA",
"Turborepo",
"Deepgram"
],
"patterns": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn
:::tip


If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

:::tip

If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/guides/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-from-sequelize) migration guides.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

<Admonition type="tip">

If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose guide](/orm/more/migrating-to-prisma/migrate-from-mongoose).
If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose guide](/guides/migrate-from-mongoose).

</Admonition>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Learn how to add Prisma ORM to an existing Node.js or TypeScript project by conn

<Admonition type="tip">

If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose guide](/orm/more/migrating-to-prisma/migrate-from-mongoose).
If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose guide](/guides/migrate-from-mongoose).

</Admonition>

Expand Down
18 changes: 12 additions & 6 deletions content/200-orm/050-overview/500-databases/500-sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ metaDescription: 'This page explains how Prisma can connect to a SQLite database
tocDepth: 3
---

<TopBlock>

The SQLite data source connector connects Prisma ORM to a [SQLite](https://www.sqlite.org/) database file. These files always have the file ending `.db` (e.g.: `dev.db`).

By default, the SQLite connector contains a database driver responsible for connecting to your database. You can use a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) (Preview) to connect to your database using a JavaScript database driver from Prisma Client.

</TopBlock>

## Example

To connect to a SQLite database file, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
```prisma file=schema.prisma
datasource db {
provider = "sqlite"
url = "file:./dev.db"
Expand Down Expand Up @@ -46,8 +42,18 @@ The SQLite connector maps the [scalar types](/orm/prisma-schema/data-model/model
| `Float` | `REAL` |
| `Decimal` | `DECIMAL` |
| `DateTime` | `NUMERIC` |
| `Json` | Not supported |
| `Json` | `JSONB` |
| `Bytes` | `BLOB` |
| `Enum` | `TEXT` |

:::warning

When using `enum` fields in SQLite, be aware of the following:

- **No database-level enforcement for correctness**: If you bypass Prisma ORM and store an invalid enum entry in the database, Prisma Client queries will fail at runtime when reading that entry.
- **No migration-level enforcement for correctness**: It's possible to end up with incorrect data after schema changes similarly to MongoDB (since the enums aren't checked by the database).

:::

## Rounding errors on big numbers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This guide discusses the concepts behind using Prisma ORM and Cloudflare D1, exp

Prisma ORM support for Cloudflare D1 is currently in [Preview](/orm/more/releases#preview). We would appreciate your feedback [on GitHub](https://github.com/prisma/prisma/discussions/23646).

If you want to deploy a Cloudflare Worker with D1 and Prisma ORM, follow this [tutorial](/orm/prisma-client/deployment/edge/deploy-to-cloudflare#cloudflare-d1).
If you want to deploy a Cloudflare Worker with D1 and Prisma ORM, follow this [tutorial](/guides/using-prisma-orm-with-cloudflare-d1).

</TopBlock>

Expand Down Expand Up @@ -45,7 +45,7 @@ There are a number of differences between D1 and SQLite to consider. You should

When using Prisma ORM with D1, you need to use the `sqlite` database provider and the `@prisma/adapter-d1` [driver adapter](/orm/overview/databases/database-drivers#driver-adapters).

If you want to deploy a Cloudflare Worker with D1 and Prisma ORM, follow these [step-by-step instructions](/orm/prisma-client/deployment/edge/deploy-to-cloudflare#cloudflare-d1).
If you want to deploy a Cloudflare Worker with D1 and Prisma ORM, follow these [step-by-step instructions](/guides/using-prisma-orm-with-cloudflare-d1).

## Migration workflows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ Every model in the data model definition will result in a number of CRUD queries
- [`createMany()`](/orm/reference/prisma-client-reference#createmany)
- [`createManyAndReturn()`](/orm/reference/prisma-client-reference#createmanyandreturn)
- [`updateMany()`](/orm/reference/prisma-client-reference#updatemany)
- [`updateManyAndReturn()`](/orm/reference/prisma-client-reference#updatemanyandreturn)
- [`deleteMany()`](/orm/reference/prisma-client-reference#deletemany)

The operations are accessible via a generated property on the Prisma Client instance. By default the name of the property is the lowercase form of the model name, e.g. `user` for a `User` model or `post` for a `Post` model.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
title: Configure Prisma Client with PgBouncer
metaTitle: Configure Prisma Client with PgBouncer
toc_max_heading_level: 2
---

<TopBlock>

An external connection pooler like PgBouncer holds a connection pool to the database, and proxies incoming client connections by sitting between Prisma Client and the database. This reduces the number of processes a database has to handle at any given time.

Usually, this works transparently, but some connection poolers only support a limited set of functionality. One common feature that external connection poolers do not support are named prepared statements, which Prisma ORM uses. For these cases, Prisma ORM can be configured to behave differently.

</TopBlock>
:::info

Looking for an easy, infrastructure-free solution? Try [Prisma Accelerate](https://www.prisma.io/accelerate?utm_source=docs&utm_campaign=pgbouncer-help)! It requires little to no setup and works seamlessly with all databases supported by Prisma ORM.

Ready to begin? Get started with Prisma Accelerate by clicking [here](https://console.prisma.io?utm_source=docs&utm_campaign=pgbouncer-help).
:::

## PgBouncer

Expand Down
57 changes: 56 additions & 1 deletion content/200-orm/200-prisma-client/100-queries/030-crud.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,6 @@ const updateUsers = await prisma.user.updateMany({
},
})
```

</cmd>
<cmdResult>

Expand All @@ -694,6 +693,62 @@ const updateUsers = await prisma.user.updateMany({
</cmdResult>
</CodeWithResult>

### Update and return multiple records

:::info

This feature is available in Prisma ORM version 6.2.0 and later for PostgreSQL, CockroachDB, and SQLite.

:::

You can use `updateManyAndReturn()` in order to update many records and return the resulting objects.

<CodeWithResult outputResultText="query">
<cmd>

```ts
const users = await prisma.user.updateManyAndReturn({
where: {
email: {
contains: 'prisma.io',
}
},
data: {
role: 'ADMIN'
}
})
```

</cmd>
<cmdResult>

```js no-copy
[{
id: 22,
name: 'Alice',
email: '[email protected]',
profileViews: 0,
role: 'ADMIN',
coinflips: []
}, {
id: 23,
name: 'Bob',
email: '[email protected]',
profileViews: 0,
role: 'ADMIN',
coinflips: []
}]
```

</cmdResult>
</CodeWithResult>

:::warning

`relationLoadStrategy: join` is not available when using `updateManyAndReturn()`.

:::

### Update _or_ create records

The following query uses [`upsert()`](/orm/reference/prisma-client-reference#upsert) to update a `User` record with a specific email address, or create that `User` record if it does not exist:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const users = await prisma.user.findFirst()
If you want to customize the result and have a different combination of fields returned, you can:

- Use [`select`](/orm/reference/prisma-client-reference#select) to return specific fields. You can also use a [nested `select`](/orm/prisma-client/queries/relation-queries#select-specific-fields-of-included-relations) by selecting relation fields.
- Use [`omit`](/orm/reference/prisma-client-reference#omit-preview) to exclude specific fields from the result. `omit` can be seen as the "opposite" to `select`.
- Use [`omit`](/orm/reference/prisma-client-reference#omit) to exclude specific fields from the result. `omit` can be seen as the "opposite" to `select`.
- Use [`include`](/orm/reference/prisma-client-reference#include) to additionally [include relations](/orm/prisma-client/queries/relation-queries#nested-reads).

In all cases, the query result will be statically typed, ensuring that you don't accidentally access any fields that you did not actually query from the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ const updatedPost: Post = await prisma.post.update({

The following bulk operations run as transactions:

- `deleteMany()`
- `updateMany()`
- `createMany()`
- `createManyAndReturn()`
- `updateMany()`
- `updateManyAndReturn()`
- `deleteMany()`

> Refer to the section about [bulk operations](#bulk-operations) for more examples.
Expand Down Expand Up @@ -776,10 +777,12 @@ Depending on your requirements, Prisma Client has four options for handling inde

Bulk writes allow you to write multiple records of the same type in a single transaction - if any operation fails, Prisma Client rolls back the entire transaction. Prisma Client currently supports:

- `updateMany()`
- `deleteMany()`
- `createMany()`
- `createManyAndReturn()`
- `updateMany()`
- `updateManyAndReturn()`
- `deleteMany()`


#### When to use bulk operations

Expand Down
Loading

0 comments on commit 40feaae

Please sign in to comment.