From 5ef20e34400b6553b71a27c873eab13606a1e75c Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Tue, 1 Aug 2023 05:10:02 -0400 Subject: [PATCH] docs: mention virtual fields cannot be sorted (#3107) --- docs/queries/overview.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/queries/overview.mdx b/docs/queries/overview.mdx index 24d2c9bc0..bdfabad6e 100644 --- a/docs/queries/overview.mdx +++ b/docs/queries/overview.mdx @@ -194,7 +194,7 @@ const getPosts = async () => { ## 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:** **`https://localhost:3000/api/posts?sort=-createdAt`**