Skip to content

Commit

Permalink
fix all relative links
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell committed Apr 8, 2024
1 parent dee403a commit d359507
Show file tree
Hide file tree
Showing 35 changed files with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The remaining parts of this page discuss how Prisma ORM compares to existing dat

The main problem with the database tools that currently exist in the Node.js and TypeScript ecosystem is that they require a major tradeoff between _productivity_ and _control_.

![Productivity vs Control in ORMs, SQL query builders, and SQL](node-js-db-tools-tradeoffs.png)
![Productivity vs Control in ORMs, SQL query builders, and SQL](./node-js-db-tools-tradeoffs.png)

### Raw SQL: Full control, low productivity

Expand Down Expand Up @@ -92,4 +92,4 @@ Developers should be able to ask for the data they need instead of having to wor

Prisma ORM's main goal is to make application developers more productive when working with databases. Considering the tradeoff between productivity and control again, this is how Prisma ORM fits in:

![Prisma ORM makes developers productive](prisma-makes-devs-productive.png)
![Prisma ORM makes developers productive](./prisma-makes-devs-productive.png)
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Notice that this code requires the `DATABASE_URL` environment variable to be set

Prisma ORM follows the connection URL format specified by [PostgreSQL's official guidelines](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING), but does not support all arguments and includes additional arguments such as `schema`. Here's an overview of the components needed for a PostgreSQL connection URL:

![Structure of the PostgreSQL connection URL](postgresql-connection-string.png)
![Structure of the PostgreSQL connection URL](./postgresql-connection-string.png)

#### Base URL and path

Expand Down
2 changes: 1 addition & 1 deletion content/200-orm/050-overview/500-databases/400-mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The fields passed to the `datasource` block are:

Here's an overview of the components needed for a MySQL connection URL:

![Structure of the MySQL connection URL](mysql-connection-string.png)
![Structure of the MySQL connection URL](./mysql-connection-string.png)

#### Base URL and path

Expand Down
4 changes: 2 additions & 2 deletions content/200-orm/100-prisma-schema/10-overview/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ metaDescription: 'The Prisma schema is the main configuration file when using Pr

The Prisma schema file (short: _schema file_, _Prisma schema_ or _schema_) is the main configuration file for your Prisma ORM setup. It is typically called `schema.prisma` and consists of the following parts:

- [**Data sources**](data-sources): Specify the details of the data sources Prisma ORM should connect to (e.g. a PostgreSQL database)
- [**Generators**](generators): Specifies what clients should be generated based on the data model (e.g. Prisma Client)
- [**Data sources**](/orm/prisma-schema/overview/data-sources): Specify the details of the data sources Prisma ORM should connect to (e.g. a PostgreSQL database)
- [**Generators**](/orm/prisma-schema/overview/generators): Specifies what clients should be generated based on the data model (e.g. Prisma Client)
- [**Data model definition**](/orm/prisma-schema/data-model): Specifies your application [models](/orm/prisma-schema/data-model/models#defining-models) (the shape of the data per data source) and their [relations](/orm/prisma-schema/data-model/relations)

See the [Prisma schema API reference](/orm/reference/prisma-schema-reference) <span class="api"></span> for detailed information about each section of the schema.
Expand Down
6 changes: 3 additions & 3 deletions content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ The properties of a model are called _fields_, which consist of:
A field's type determines its _structure_, and fits into one of two categories:

- [Scalar types](#scalar-fields) (includes [enums](#defining-enums)) that map to columns (relational databases) or document fields (MongoDB) in the database - for example, [`String`](/orm/reference/prisma-schema-reference#string) or [`Int`](/orm/reference/prisma-schema-reference#int)
- Model types (the field is then called [relation field](relations#relation-fields)) - for example `Post` or `Comment[]`.
- Model types (the field is then called [relation field](/orm/prisma-schema/data-model/relations#relation-fields)) - for example `Post` or `Comment[]`.

The following table describes `User` model's fields from the sample schema:

Expand Down Expand Up @@ -438,7 +438,7 @@ model Comment {
</TabItem>
</TabbedContent>

Refer to the [relations documentation](relations) for more examples and information about relationships between models.
Refer to the [relations documentation](/orm/prisma-schema/data-model/relations) for more examples and information about relationships between models.

### Native types mapping

Expand Down Expand Up @@ -1156,7 +1156,7 @@ Support for [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincre

## Relations

Refer to the [relations documentation](relations) for more examples and information about relationships between models.
Refer to the [relations documentation](/orm/prisma-schema/data-model/relations) for more examples and information about relationships between models.

## Models in Prisma Client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ CREATE TABLE "Profile" (
);
```

Notice that there is a `UNIQUE` constraint on the foreign key `userId`. If this `UNIQUE` constraint was missing, the relation would be considered a [1-n relation](one-to-many-relations).
Notice that there is a `UNIQUE` constraint on the foreign key `userId`. If this `UNIQUE` constraint was missing, the relation would be considered a [1-n relation](/orm/prisma-schema/data-model/relations/one-to-many-relations).

The following example demonstrates how to create a 1-1 relation in SQL using a composite key (`firstName` and `lastName`):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ALTER TABLE "CategoriesOnPosts" ADD CONSTRAINT "CategoriesOnPosts_postId_fkey" F
ALTER TABLE "CategoriesOnPosts" ADD CONSTRAINT "CategoriesOnPosts_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
```

Note that the same rules as for [1-n relations](one-to-many-relations) apply (because `Post``CategoriesOnPosts` and `Category``CategoriesOnPosts` are both in fact 1-n relations), which means one side of the relation needs to be annotated with the `@relation` attribute.
Note that the same rules as for [1-n relations](/orm/prisma-schema/data-model/relations/one-to-many-relations) apply (because `Post``CategoriesOnPosts` and `Category``CategoriesOnPosts` are both in fact 1-n relations), which means one side of the relation needs to be annotated with the `@relation` attribute.

When you don't need to attach additional information to the relation, you can model m-n-relations as [implicit m-n-relations](#implicit-many-to-many-relations). If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit m-n-relations by following Prisma ORM's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ This relation expresses the following:
- "a user can be followed by zero or more users"
- "a user can follow zero or more users"

Note that for relational databases, this many-to-many-relation is [implicit](many-to-many-relations#implicit-many-to-many-relations). This means Prisma ORM maintains a [relation table](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) for it in the underlying database.
Note that for relational databases, this many-to-many-relation is [implicit](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations). This means Prisma ORM maintains a [relation table](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) for it in the underlying database.

If you need the relation to hold other fields, you can create an [explicit](many-to-many-relations#explicit-many-to-many-relations) many-to-many self relation as well. The explicit version of the self relation shown previously is as follows:
If you need the relation to hold other fields, you can create an [explicit](/orm/prisma-schema/data-model/relations/many-to-many-relations#explicit-many-to-many-relations) many-to-many self relation as well. The explicit version of the self relation shown previously is as follows:

```prisma
model User {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ model Post {

If you use the [Prisma VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) (or our [language server in another editor](/orm/more/development-environment/editor-setup)), the warning is augmented with a Quick Fix that adds the required index for you:

![The Quick Fix pop-up for adding an index on a relation scalar field in VS Code](quick-fix-index.png)
![The Quick Fix pop-up for adding an index on a relation scalar field in VS Code](./quick-fix-index.png)

## Switch between relation modes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ If you rename relation fields in an implicit many-to-many self-relations, make s

## How to use a relation table with a many-to-many relationship

There are a couple of ways to define a m-n relationship, implicitly or explicitly. Implicitly means letting Prisma ORM handle the relation table (JOIN table) under the hood, all you have to do is define an array/list for the non scalar types on each model, see [implicit many-to-many relations](many-to-many-relations#implicit-many-to-many-relations).
There are a couple of ways to define a m-n relationship, implicitly or explicitly. Implicitly means letting Prisma ORM handle the relation table (JOIN table) under the hood, all you have to do is define an array/list for the non scalar types on each model, see [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations).

Where you might run into trouble is when creating an [explicit m-n relationship](many-to-many-relations#explicit-many-to-many-relations), that is, to create and handle the relation table yourself. **It can be overlooked that Prisma ORM requires both sides of the relation to be present**.
Where you might run into trouble is when creating an [explicit m-n relationship](/orm/prisma-schema/data-model/relations/many-to-many-relations#explicit-many-to-many-relations), that is, to create and handle the relation table yourself. **It can be overlooked that Prisma ORM requires both sides of the relation to be present**.

Take the following example, here a relation table is created to act as the JOIN between the `Post` and `Category` tables. This will not work however as the relation table (`PostCategories`) must form a 1-to-many relationship with the other two models respectively.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ In this query, the current value of `authorID` does not matter. The query change

There are three different types (or [cardinalities](<https://en.wikipedia.org/wiki/Cardinality_(data_modeling)>)) of relations in Prisma ORM:

- [One-to-one](one-to-one-relations) (also called 1-1 relations)
- [One-to-many](one-to-many-relations) (also called 1-n relations)
- [Many-to-many](many-to-many-relations) (also called m-n relations)
- [One-to-one](/orm/prisma-schema/data-model/relations/one-to-one-relations) (also called 1-1 relations)
- [One-to-many](/orm/prisma-schema/data-model/relations/one-to-many-relations) (also called 1-n relations)
- [Many-to-many](/orm/prisma-schema/data-model/relations/many-to-many-relations) (also called m-n relations)

The following Prisma schema includes every type of relation:

Expand Down Expand Up @@ -305,11 +305,11 @@ This example uses [implicit many-to-many relations](/orm/prisma-schema/data-mode

</Admonition>

Notice that the syntax is slightly different between relational databases and MongoDB - particularly for [many-to-many relations](many-to-many-relations).
Notice that the syntax is slightly different between relational databases and MongoDB - particularly for [many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations).

For relational databases, the following entity relationship diagram represents the database that corresponds to the sample Prisma schema:

![The sample schema as an entity relationship diagram](sample-schema.png)
![The sample schema as an entity relationship diagram](./sample-schema.png)

For MongoDB, Prisma ORM uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. See [the MongoDB section](#mongodb) for more details.

Expand All @@ -331,7 +331,7 @@ The implicit many-to-many relation still manifests in a relation table in the un

If you use an implicit many-to-many relation instead of an explicit one, it makes the [Prisma Client API](/orm/prisma-client) simpler (because, for example, you have one fewer level of nesting inside of [nested writes](/orm/prisma-client/queries/relation-queries#nested-writes)).

If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit many-to-many relations by following Prisma ORM's [conventions for relation tables](many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations).
If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit many-to-many relations by following Prisma ORM's [conventions for relation tables](/orm/prisma-schema/data-model/relations/many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations).

## Relation fields

Expand Down Expand Up @@ -474,11 +474,11 @@ The `@relation` attribute is required when:

- you define a one-to-one or one-to-many relation, it is required on _one side_ of the relation (with the corresponding relation scalar field)
- you need to disambiguate a relation (that's e.g. the case when you have two relations between the same models)
- you define a [self-relation](self-relations)
- you define [a many-to-many relation for MongoDB](many-to-many-relations#mongodb)
- you define a [self-relation](/orm/prisma-schema/data-model/relations/self-relations)
- you define [a many-to-many relation for MongoDB](/orm/prisma-schema/data-model/relations/many-to-many-relations#mongodb)
- you need to control how the relation table is represented in the underlying database (e.g. use a specific name for a relation table)

> **Note**: [Implicit many-to-many relations](many-to-many-relations#implicit-many-to-many-relations) in relational databases do not require the `@relation` attribute.
> **Note**: [Implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations) in relational databases do not require the `@relation` attribute.
## Disambiguating relations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To generate and instantiate Prisma Client:
prisma generate
```

1. You can now [instantiate Prisma Client](instantiate-prisma-client) in your code:
1. You can now [instantiate Prisma Client](/orm/prisma-client/setup-and-configuration/instantiate-prisma-client) in your code:

<TabbedContent code>

Expand Down Expand Up @@ -68,7 +68,7 @@ To generate and instantiate Prisma Client:
Here is a graphical illustration of the typical workflow for generation of Prisma Client:

![Graphical illustration of the typical workflow for generation of Prisma Client](prisma-client-generation-workflow.png)
![Graphical illustration of the typical workflow for generation of Prisma Client](./prisma-client-generation-workflow.png)

Note also that `prisma generate` is _automatically_ invoked when you're installing the `@prisma/client` npm package. So, when you're initially setting up Prisma Client, you can typically save the third step from the list above.

Expand All @@ -95,7 +95,7 @@ import { PrismaClient } from '@prisma/client'

Prisma Client is generated from your Prisma schema and is unique to your project. Each time you change the schema (for example, by performing a [schema migration](/orm/prisma-migrate)) and run `prisma generate`, Prisma Client's code changes:

![The .prisma and @prisma folders](prisma-client-node-module.png)
![The .prisma and @prisma folders](./prisma-client-node-module.png)

The `.prisma` folder is unaffected by [pruning](https://docs.npmjs.com/cli/prune.html) in Node.js package managers.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tocDepth: 3

<TopBlock title={frontMatter.title}>

The following example demonstrates how to import and instantiate your [generated client](generating-prisma-client) from the [default path](generating-prisma-client#using-a-custom-output-path):
The following example demonstrates how to import and instantiate your [generated client](/orm/prisma-client/setup-and-configuration/generating-prisma-client) from the [default path](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path):

</TopBlock>

Expand Down Expand Up @@ -37,7 +37,7 @@ const prisma = new PrismaClient()

:::tip

You can further customize `PrismaClient` with [constructor parameters](/orm/reference/prisma-client-reference#prismaclient) - for example, set [logging levels](/orm/prisma-client/observability-and-logging/logging) or customize [error formatting](error-formatting).
You can further customize `PrismaClient` with [constructor parameters](/orm/reference/prisma-client-reference#prismaclient) - for example, set [logging levels](/orm/prisma-client/observability-and-logging/logging) or customize [error formatting](/orm/prisma-client/setup-and-configuration/error-formatting).

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tocDepth: 3
- [`$connect()`](/orm/reference/prisma-client-reference#connect-1)
- [`$disconnect()`](/orm/reference/prisma-client-reference#disconnect-1)

In most cases, you **do not need to explicitly call these methods**. `PrismaClient` automatically connects when you run your first query, creates a [connection pool](connection-pool), and disconnects when the Node.js process ends.
In most cases, you **do not need to explicitly call these methods**. `PrismaClient` automatically connects when you run your first query, creates a [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool), and disconnects when the Node.js process ends.

See the [connection management guide](/orm/prisma-client/setup-and-configuration/databases-connections) for information about managing connections for different deployment paradigms (long-running processes and serverless functions).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ toc_max_heading_level: 4

The query engine manages a **connection pool** of database connections. The pool is created when Prisma Client opens the _first_ connection to the database, which can happen in one of two ways:

- By [explicitly calling `$connect()`](connection-management#connect) _or_
- By [explicitly calling `$connect()`](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management#connect) _or_
- By running the first query, which calls `$connect()` under the hood

Relational database connectors use Prisma ORM's own connection pool, and the MongoDB connectors uses the [MongoDB driver connection pool](https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst).
Expand Down
Loading

0 comments on commit d359507

Please sign in to comment.