chore: bump prettier, re-enable prettier for docs (#11695)

## Introducing Prettier for docs

Prettier [was originally disabled for our docs as it didn't support MDX
2.0](1fa636417f),
outputting invalid MDX syntax.

This has since been fixed - prettier now supports MDX 2.0.

## Reducing print width

This also reduces the print width for the docs folder from 100 to 70.
Our docs code field are very narrow - this should help make code more
readable.

**Before**
![CleanShot 2025-03-13 at 19 58
11@2x](https://github.com/user-attachments/assets/0ae9e27b-cddf-44e5-a978-c8e24e99a314)

**After**

![CleanShot 2025-03-13 at 19 59
19@2x](https://github.com/user-attachments/assets/0e424f99-002c-4adc-9b37-edaeef239b0d)



**Before**
![CleanShot 2025-03-13 at 20 00
05@2x](https://github.com/user-attachments/assets/614e51b3-aa0d-45e7-98f4-fcdb1a778bcf)

**After**

![CleanShot 2025-03-13 at 20 00
16@2x](https://github.com/user-attachments/assets/be46988a-2cba-43fc-a8cd-fd3c781da930)
This commit is contained in:
Alessio Gravili
2025-03-14 11:13:08 -06:00
committed by GitHub
parent 9ea8a7acf0
commit 9f9db3ff81
121 changed files with 3721 additions and 3404 deletions

View File

@@ -34,8 +34,8 @@ But with a `depth` of `1`, the response might look like this:
```
<Banner type="warning">
**Important:**
Depth has no effect in the [GraphQL API](../graphql/overview), because there, depth is based on the shape of your queries.
**Important:** Depth has no effect in the [GraphQL API](../graphql/overview),
because there, depth is based on the shape of your queries.
</Banner>
## Local API
@@ -56,8 +56,8 @@ const getPosts = async (payload: Payload) => {
```
<Banner type="info">
**Reminder:**
This is the same for [Globals](../configuration/globals) using the `findGlobal` operation.
**Reminder:** This is the same for [Globals](../configuration/globals) using
the `findGlobal` operation.
</Banner>
## REST API
@@ -71,8 +71,8 @@ fetch('https://localhost:3000/api/posts?depth=2') // highlight-line
```
<Banner type="info">
**Reminder:**
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
**Reminder:** This is the same for [Globals](../configuration/globals) using
the `/api/globals` endpoint.
</Banner>
## Max Depth

View File

@@ -31,35 +31,36 @@ const query: Where = {
_The exact query syntax will depend on the API you are using, but the concepts are the same across all APIs. [More details](#writing-queries)._
<Banner>
**Tip:**
You can also use queries within [Access Control](../access-control/overview) functions.
**Tip:** You can also use queries within [Access
Control](../access-control/overview) functions.
</Banner>
## Operators
The following operators are available for use in queries:
| Operator | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `equals` | The value must be exactly equal. |
| `not_equals` | The query will return all documents where the value is not equal. |
| `greater_than` | For numeric or date-based fields. |
| `greater_than_equal` | For numeric or date-based fields. |
| `less_than` | For numeric or date-based fields. |
| `less_than_equal` | For numeric or date-based fields. |
| `like` | Case-insensitive string must be present. If string of words, all words must be present, in any order. |
| `contains` | Must contain the value entered, case-insensitive. |
| `in` | The value must be found within the provided comma-delimited list of values. |
| `not_in` | The value must NOT be within the provided comma-delimited list of values. |
| `all` | The value must contain all values provided in the comma-delimited list. Note: currently this operator is supported only with the MongoDB adapter. |
| `exists` | Only return documents where the value either exists (`true`) or does not exist (`false`). |
| `near` | For distance related to a [Point Field](../fields/point) comma separated as `<longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>`. |
| `within` | For [Point Fields](../fields/point) to filter documents based on whether points are inside of the given area defined in GeoJSON. [Example](../fields/point#querying-within) |
| `intersects` | For [Point Fields](../fields/point) to filter documents based on whether points intersect with the given area defined in GeoJSON. [Example](../fields/point#querying-intersects) |
| Operator | Description |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `equals` | The value must be exactly equal. |
| `not_equals` | The query will return all documents where the value is not equal. |
| `greater_than` | For numeric or date-based fields. |
| `greater_than_equal` | For numeric or date-based fields. |
| `less_than` | For numeric or date-based fields. |
| `less_than_equal` | For numeric or date-based fields. |
| `like` | Case-insensitive string must be present. If string of words, all words must be present, in any order. |
| `contains` | Must contain the value entered, case-insensitive. |
| `in` | The value must be found within the provided comma-delimited list of values. |
| `not_in` | The value must NOT be within the provided comma-delimited list of values. |
| `all` | The value must contain all values provided in the comma-delimited list. Note: currently this operator is supported only with the MongoDB adapter. |
| `exists` | Only return documents where the value either exists (`true`) or does not exist (`false`). |
| `near` | For distance related to a [Point Field](../fields/point) comma separated as `<longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>`. |
| `within` | For [Point Fields](../fields/point) to filter documents based on whether points are inside of the given area defined in GeoJSON. [Example](../fields/point#querying-within) |
| `intersects` | For [Point Fields](../fields/point) to filter documents based on whether points intersect with the given area defined in GeoJSON. [Example](../fields/point#querying-intersects) |
<Banner type="success">
**Tip:**
If you know your users will be querying on certain fields a lot, add `index: true` to the Field Config. This will speed up searches using that field immensely.
**Tip:** If you know your users will be querying on certain fields a lot, add
`index: true` to the Field Config. This will speed up searches using that
field immensely.
</Banner>
### And / Or Logic
@@ -72,14 +73,16 @@ To join queries, use the `and` or `or` keys in your query object:
import type { Where } from 'payload'
const query: Where = {
or: [ // highlight-line
or: [
// highlight-line
{
color: {
equals: 'mint',
},
},
{
and: [ // highlight-line
and: [
// highlight-line
{
color: {
equals: 'white',
@@ -183,7 +186,9 @@ const getPosts = async () => {
{ addQueryPrefix: true },
)
const response = await fetch(`http://localhost:3000/api/posts${stringifiedQuery}`)
const response = await fetch(
`http://localhost:3000/api/posts${stringifiedQuery}`,
)
// Continue to handle the response below...
}
```

View File

@@ -25,7 +25,7 @@ const getPosts = async (payload: Payload) => {
text: true,
// select a specific field from group
group: {
number: true
number: true,
},
// select all fields from array
array: true,
@@ -43,8 +43,8 @@ const getPosts = async (payload: Payload) => {
select: {
array: false,
group: {
number: false
}
number: false,
},
}, // highlight-line
})
@@ -52,20 +52,23 @@ const getPosts = async (payload: Payload) => {
}
```
<Banner type="warning">
**Important:**
To perform querying with `select` efficiently, Payload implements your `select` query on the database level. Because of that, your `beforeRead` and `afterRead` hooks may not receive the full `doc`.
To ensure that some fields are always selected for your hooks / access control, regardless of the `select` query you can use `forceSelect` collection config property.
**Important:** To perform querying with `select` efficiently, Payload
implements your `select` query on the database level. Because of that, your
`beforeRead` and `afterRead` hooks may not receive the full `doc`. To ensure
that some fields are always selected for your hooks / access control,
regardless of the `select` query you can use `forceSelect` collection config
property.
</Banner>
## REST API
To specify select in the [REST API](../rest-api/overview), you can use the `select` parameter in your query:
```ts
fetch('https://localhost:3000/api/posts?select[color]=true&select[group][number]=true') // highlight-line
fetch(
'https://localhost:3000/api/posts?select[color]=true&select[group][number]=true',
) // highlight-line
.then((res) => res.json())
.then((data) => console.log(data))
```
@@ -81,8 +84,8 @@ import type { Where } from 'payload'
const select: Where = {
text: true,
group: {
number: true
}
number: true,
},
// This query could be much more complex
// and QS would handle it beautifully
}
@@ -95,17 +98,18 @@ const getPosts = async () => {
{ addQueryPrefix: true },
)
const response = await fetch(`http://localhost:3000/api/posts${stringifiedQuery}`)
const response = await fetch(
`http://localhost:3000/api/posts${stringifiedQuery}`,
)
// Continue to handle the response below...
}
```
<Banner type="info">
**Reminder:**
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
**Reminder:** This is the same for [Globals](../configuration/globals) using
the `/api/globals` endpoint.
</Banner>
## defaultPopulate collection config property
The `defaultPopulate` property allows you specify which fields to select when populating the collection from another document.
@@ -139,8 +143,10 @@ export const Pages: CollectionConfig<'pages'> = {
```
<Banner type="warning">
**Important:**
When using `defaultPopulate` on a collection with [Uploads](/docs/fields/upload) enabled and you want to select the `url` field, it is important to specify `filename: true` as well, otherwise Payload will not be able to construct the correct file URL, instead returning `url: null`.
**Important:** When using `defaultPopulate` on a collection with
[Uploads](/docs/fields/upload) enabled and you want to select the `url` field,
it is important to specify `filename: true` as well, otherwise Payload will
not be able to construct the correct file URL, instead returning `url: null`.
</Banner>
## populate
@@ -175,4 +181,4 @@ const getPosts = async (payload: Payload) => {
fetch('https://localhost:3000/api/posts?populate[pages][text]=true') // highlight-line
.then((res) => res.json())
.then((data) => console.log(data))
```
```

View File

@@ -11,8 +11,8 @@ Documents in Payload can be easily sorted by a specific [Field](../fields/overvi
Because sorting is handled by the database, the field cannot be a [Virtual Field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It must be stored in the database to be searchable.
<Banner type="success">
**Tip:**
For performance reasons, it is recommended to enable `index: true` for the fields that will be sorted upon. [More details](../fields/overview).
**Tip:** For performance reasons, it is recommended to enable `index: true`
for the fields that will be sorted upon. [More details](../fields/overview).
</Banner>
## Local API