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 apps/docs/content/docs/guides/next/frameworks/elysia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ In a long-running server, don't call `db.close()` in route handlers; the client'

## Prompt your coding agent

The scaffold installs Prisma Next skills for your coding agent. Prompts that map to this guide:
The scaffold installs [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent. Prompts that map to this guide:

- "Using the prisma-next-queries skill, add GET /users/:id that returns one user or a 404."
- "Add a POST /users route that creates a user from the request body."
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/guides/next/frameworks/hono.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ In a long-running server, don't call `db.close()` in route handlers; the client'

## Prompt your coding agent

The scaffold installs Prisma Next skills for your coding agent. Prompts that map to this guide:
The scaffold installs [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent. Prompts that map to this guide:

- "Using the prisma-next-queries skill, add GET /users/:id that returns one user or a 404."
- "Add a Post model related to User, update the database, and expose GET /users/:id/posts."
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/guides/next/runtimes/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ That is the whole loop: schema to contract, contract to database, typed queries

## Prompt your coding agent

The scaffold installs Prisma Next skills for your coding agent. Prompts that map to this guide:
The scaffold installs [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent. Prompts that map to this guide:

- "Using the prisma-next-queries skill, add a script that lists the 10 newest users."
- "Add a Post model related to User, emit the contract, and update the database."
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/guides/next/runtimes/deno.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Deno reports `Unsupported compiler options in tsconfig.json` for a few options t

## Prompt your coding agent

The scaffold installs Prisma Next skills for your coding agent. Prompts that map to this guide:
The scaffold installs [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent. Prompts that map to this guide:

- "Using the prisma-next-queries skill, add a Deno task that prints every user created in the last day."
- "Tighten the Deno permissions for this project from -A to an explicit allow list."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Capabilities record what your database stack supports, so Prisma Ne
url: /orm/next/contract-authoring/capabilities
metaTitle: Capabilities in Prisma Next
metaDescription: How Prisma Next capabilities are derived from the target, adapter, and extension packs, what they gate, and what happens when a required capability is missing.
badge: early-access
---

Not every database stack supports every feature. One setup can run lateral joins, `RETURNING` clauses, and vector distance operations; another cannot.
Expand Down Expand Up @@ -86,7 +87,7 @@ Extensions are the main source of capabilities beyond the core; [Using extension

## Prompt your coding agent

Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/skills) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:

- "Which capabilities does our contract currently require, and which package provides each?"
- "Add pgvector to the project and confirm the capability shows up in the emitted contract."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Write the Prisma Next contract as a Prisma schema file, using the s
url: /orm/next/contract-authoring/psl-syntax
metaTitle: Author the Prisma Next contract in PSL
metaDescription: Learn how to write a Prisma Next contract in the Prisma schema language, including named types, enums, value objects, relations, and extension types.
badge: early-access
---

PSL is the preferred way to author the Prisma Next [data contract](/orm/next/contract-authoring/the-data-contract). You write a Prisma schema file, usually `prisma/contract.prisma`, and [`prisma-next contract emit`](/cli/next/contract-emit) turns it into `contract.json` and `contract.d.ts`.
Expand Down Expand Up @@ -309,7 +310,7 @@ The syntax above declares relations; for which shape to choose and which side ow

## Prompt your coding agent

Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/skills) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:

- "Using the prisma-next-contract skill, add a Status enum stored as text and use it on the Order model."
- "Add a one-to-many between User and Post with the foreign key on Post."
Expand All @@ -318,5 +319,5 @@ Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/
## Next steps

- Emit and inspect [the artifacts](/orm/next/contract-authoring/the-contract-artifact) the schema produces.
- Prefer defining models in code? See [authoring in TypeScript](/orm/next/contract-authoring/typescript-schema-builder).
- If you prefer defining models in code, see [authoring in TypeScript](/orm/next/contract-authoring/typescript-schema-builder).
- Apply the contract to a database with [`prisma-next db init`](/cli/next/db-init) or plan changes with [`prisma-next migration plan`](/cli/next/migration-plan).
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: contract.json and contract.d.ts are the deterministic artifacts eve
url: /orm/next/contract-authoring/the-contract-artifact
metaTitle: The Prisma Next contract artifacts
metaDescription: What contract.json and contract.d.ts contain, how deterministic emission and content hashes work, and how the runtime and tooling consume the artifacts.
badge: early-access
---

Emitting your contract produces two generated files. This page explains what is in each, why they are deterministic, and how their hashes keep your code and your database in agreement.
Expand Down Expand Up @@ -104,7 +105,7 @@ An abridged emit of a `User`/`Post` schema:
The sections, top to bottom:

- **`schemaVersion`, `targetFamily`, `target`**: the contract format version and the database this contract targets.
- **`roots`**: the accessor names your queries start from, each mapping to a model. `db.user` exists because `roots.user` points at `User`.
- **`roots`**: the accessor names your queries start from, each mapping to a model. The SQL builder's `db.sql.public.user` exists because `roots.user` points at `User`, and the model it names is what the ORM accessor `db.orm.public.User` hangs off.
- **`domain`**: the application's view. Each field carries `nullable` and a `codecId` such as `pg/text@1`, which names the codec that encodes and decodes values of that type. Relations record cardinality and the fields they join on. The model's `storage` block maps fields to columns.
- **`storage`**: the database's view: tables with columns (native type plus codec), primary keys, uniques, indexes, foreign keys, and value sets backing enums. This is the section migration tooling diffs and `db verify` checks the live schema against.
- **`execution`**: defaults Prisma Next applies before writes, such as UUID generation, kept out of the database's DDL.
Expand Down Expand Up @@ -152,7 +153,7 @@ Commit the artifacts alongside the source. They contain structure only, no data

## Prompt your coding agent

Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/skills) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:

- "Explain the difference between contract.json and contract.d.ts in this project."
- "Re-emit the contract and show me what changed in the artifact."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: The data contract is the single description of your data model and
url: /orm/next/contract-authoring/the-data-contract
metaTitle: The Prisma Next data contract
metaDescription: What the Prisma Next data contract is, how PSL and TypeScript authoring produce the same artifacts, and how the contract drives typing, migrations, and verification.
badge: early-access
---

Every Prisma Next project has one description of its data: the models, their fields, and how they map to database tables. That description is the data contract.
Expand Down Expand Up @@ -92,7 +93,7 @@ It contains no rows, no credentials, and no connection details, so committing th

## Prompt your coding agent

Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/skills) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:

- "Using the prisma-next-contract skill, explain what our contract.json currently declares."
- "Add an Invoice model to the contract and emit it."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Define the Prisma Next contract with a typed builder API instead of
url: /orm/next/contract-authoring/typescript-schema-builder
metaTitle: Author the Prisma Next contract in TypeScript
metaDescription: Learn how to define a Prisma Next contract in TypeScript with defineContract, including fields, relations, enums, storage mapping, and extension types.
badge: early-access
---

TypeScript authoring defines the Prisma Next [data contract](/orm/next/contract-authoring/the-data-contract) in code. Instead of a `.prisma` file, you write `prisma/contract.ts` with the `defineContract` builder, and [`prisma-next contract emit`](/cli/next/contract-emit) produces exactly the same `contract.json` and `contract.d.ts` a PSL schema would.
Expand Down Expand Up @@ -207,7 +208,7 @@ Post.relations({
});
```

`rel.hasMany(Model, { by })` names the foreign key field on the other model; `rel.belongsTo(Model, { from, to })` maps the local foreign key field to the referenced field. `rel.hasOne` and `rel.manyToMany` cover the remaining shapes. Because the arguments are model objects, not strings, a typo in a relation target is a compile error.
`rel.hasMany(Model, { by })` names the foreign key field on the other model; `rel.belongsTo(Model, { from, to })` maps the local foreign key field to the referenced field. `rel.hasOne` and `rel.manyToMany` cover the remaining shapes. A typo in a relation target is a compile error either way: the PostgreSQL builder takes model objects, and the MongoDB builder takes model names that are type-checked against the declared models.

## Storage mapping

Expand Down Expand Up @@ -265,7 +266,7 @@ TypeScript and [PSL](/orm/next/contract-authoring/psl-syntax) authoring emit the

## Prompt your coding agent

Projects scaffolded with `create-prisma` install [Prisma Next skills](/ai/tools/skills) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers this page. Ask your agent to:

- "Convert this contract.prisma to the TypeScript schema builder."
- "Using the prisma-next-contract skill, add a unique index to the email field in our TypeScript schema."
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/docs/orm/next/data-modeling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In Prisma Next, you define this structure in a `contract.prisma` file. This file

If you are coming from Prisma 7, `contract.prisma` plays a similar role to the `schema.prisma` file you used before.

This page introduces the four building blocks of every Prisma Next schema:
This page introduces the four building blocks of every Prisma Next contract:

- [Models](#models): the things your application works with
- [Primary keys](#primary-keys): how each record is identified
Expand Down Expand Up @@ -234,11 +234,11 @@ How each shape is stored, and which model should hold the connecting field, is w

## Prompt your coding agent

Projects scaffolded with `create-prisma` install Prisma Next skills for your coding agent; the `prisma-next-contract` skill covers schema authoring. Prompts that map to each section:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers contract authoring. Prompts that map to each section:

- "Using the prisma-next-contract skill, add a Product model with a surrogate id and a unique sku field."
- "Add a Country reference table keyed by its ISO code."
- "Review my schema for fields that should be an enum or a DateTime instead of a String."
- "Review my contract for fields that should be an enum or a DateTime instead of a String."
- "Connect Post to User with a foreign key and a relation field."

## Next steps
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/orm/next/data-modeling/mongodb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ badge: early-access

MongoDB stores data as documents grouped into collections. A document can nest objects and arrays directly, which gives you a real choice for related data: keep it inside the document (embed it) or store it in its own collection and link to it (reference it).

Making that choice well is the core of MongoDB data modeling, and it is what this page focuses on. New to models and keys? Start with the [data modeling overview](/orm/next/data-modeling).
Making that choice well is the core of MongoDB data modeling, and it is what this page focuses on. If you are new to models and keys, start with the [data modeling overview](/orm/next/data-modeling).

## Documents, collections, and the _id key

Expand Down Expand Up @@ -154,7 +154,7 @@ Use one polymorphic collection when the variants are handled together far more t

## Prompt your coding agent

Projects scaffolded with `create-prisma` install Prisma Next skills for your coding agent; the `prisma-next-contract` skill covers document modeling. Prompts that map to each section:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers document modeling. Prompts that map to each section:

- "Using the prisma-next-contract skill, add an embedded Address type to the User model."
- "Cart items are always read with the cart. Model them as an embedded list."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ badge: early-access

In a relational database, each model becomes a table and each scalar field becomes a column. Models connect through foreign keys: a column in one table that holds the primary key of a row in another table.

This page shows how to model each relation shape and, for each one, where the foreign key belongs. New to models and keys? Start with the [data modeling overview](/orm/next/data-modeling).
This page shows how to model each relation shape and, for each one, where the foreign key belongs. If you are new to models and keys, start with the [data modeling overview](/orm/next/data-modeling).

## How relations are declared

Expand Down Expand Up @@ -201,7 +201,7 @@ Use polymorphism when you query the variants together (one feed of tasks, one st

## Prompt your coding agent

Projects scaffolded with `create-prisma` install Prisma Next skills for your coding agent; the `prisma-next-contract` skill covers relation modeling. Prompts that map to each section:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-contract` skill covers relation modeling. Prompts that map to each section:

- "Using the prisma-next-contract skill, add a one-to-many between User and Post with the foreign key on Post."
- "Make the Profile relation one-to-one by adding a unique constraint to its foreign key."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The point of this bookkeeping is failing early:

## Available extensions

Want an extension that does not exist yet? Build it: the catalog is first-party today and built for community authors, extension packs are versioned npm packages with a documented layout, and the [call for extension authors](https://www.prisma.io/blog/prisma-next-call-for-extension-authors) explains how to write and publish one.
You can build an extension that does not exist yet. The catalog is first-party today and built for community authors, extension packs are versioned npm packages with a documented layout, and the [call for extension authors](https://www.prisma.io/blog/prisma-next-call-for-extension-authors) explains how to write and publish one.

| Extension | Adds | Package |
| --- | --- | --- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Use the SQL query builder on PostgreSQL and the pipeline builder on
url: /orm/next/fundamentals/advanced-queries
metaTitle: Advanced queries in Prisma Next
metaDescription: Use the Prisma Next SQL query builder for explicit joins, grouped aggregates, and RETURNING, and the typed aggregation pipeline builder on MongoDB.
badge: early-access
---

When the ORM API can't express a query, drop one level: the SQL query builder on PostgreSQL, or the pipeline builder on MongoDB. Both stay typed against your contract; neither means writing raw strings.
Expand All @@ -25,7 +26,7 @@ The SQL query builder composes a single SQL statement as a typed *plan*: a descr

### Build and run a plan

Start from a table with `db.sql.public.<table>` (tables use lowercase storage names), chain clauses, and call `.build()`. Execute the plan with the runtime:
Start from a table with `db.sql.public.<table>` (tables use the contract's mapped table names (snake_case storage names)), chain clauses, and call `.build()`. Execute the plan with the runtime:

```typescript
import { db } from "./prisma/db";
Expand Down Expand Up @@ -65,7 +66,7 @@ const postsWithAuthors = await db.runtime().execute(plan);
Chain more joins for multi-hop traversals. This is how you get a flat post-tag list through a [many-to-many junction table](/orm/next/fundamentals/relations-and-joins#many-to-many), one row per pair:

```typescript
const plan = db.sql.public.postTag
const plan = db.sql.public.post_tag
.as("pt")
.innerJoin(db.sql.public.tag.as("t"), (f, fns) => fns.eq(f.pt.tagId, f.t.id))
.innerJoin(db.sql.public.post.as("p"), (f, fns) => fns.eq(f.pt.postId, f.p.id))
Expand Down Expand Up @@ -231,7 +232,7 @@ Plans execute through `db.runtime().execute(plan)` on PostgreSQL and `(await db.

## Prompt your coding agent

Projects scaffolded with `create-prisma` install Prisma Next skills for your coding agent; the `prisma-next-queries` skill covers both builders and the choice between them and the ORM API. Prompts that map to each section:
Projects scaffolded with `create-prisma@next` install [Prisma Next skills](/ai/tools/skills#available-skills-for-prisma-next) for your coding agent; the `prisma-next-queries` skill covers both builders and the choice between them and the ORM API. Prompts that map to each section:

- "Using the prisma-next-queries skill, write a SQL builder plan for the top 10 authors by post count."
- "This report needs post and author columns in one flat result. Build the join with the SQL query builder."
Expand Down
Loading
Loading