docs: mention virtual fields cannot be sorted (#3107)
This commit is contained in:
@@ -194,7 +194,7 @@ const getPosts = async () => {
|
|||||||
|
|
||||||
## Sort
|
## Sort
|
||||||
|
|
||||||
Payload `find` queries support a `sort` parameter through all APIs. Pass the `name` of a top-level field to sort by that field in ascending order. Prefix the name of the field with a minus symbol ("-") to sort in descending order.
|
Payload `find` queries support a `sort` parameter through all APIs. Pass the `name` of a top-level field to sort by that field in ascending order. Prefix the name of the field with a minus symbol ("-") to sort in descending order. Because sorting is handled by the database, the field you wish to sort on must be stored in the database to work; not a [virtual field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It is recommended to enable indexing for the fields where sorting is used.
|
||||||
|
|
||||||
**REST example:**
|
**REST example:**
|
||||||
**`https://localhost:3000/api/posts?sort=-createdAt`**
|
**`https://localhost:3000/api/posts?sort=-createdAt`**
|
||||||
|
|||||||
Reference in New Issue
Block a user