docs: added details about sort order in pagination (#3824)

This commit is contained in:
Shahed Nasser
2023-04-13 14:53:34 +03:00
committed by GitHub
parent 4f58ddee03
commit 69bea8cc13
3 changed files with 34 additions and 1 deletions

View File

@@ -222,6 +222,24 @@ info:
For example, if the `count` is 100 and the `limit` is 50, you can divide the `count` by the `limit` to get the number of pages: `100/50 = 2 pages`.
### Sort Order
The `order` field available on endpoints supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their `created_at` attribute by setting `order` to `created_at`:
```bash
curl "http://localhost:9000/admin/products?order=created_at" \
-H 'Authorization: Bearer {api_token}'
```
By default, the sort direction will be ascending. To change it to descending, pass a dash (`-`) before the attribute name. For example:
```bash
curl "http://localhost:9000/admin/products?order=-created_at" \
-H 'Authorization: Bearer {api_token}'
```
This sorts the products by their `created_at` attribute in the descending order.
license:
name: MIT
url: https://github.com/medusajs/medusa/blob/master/LICENSE

View File

@@ -205,6 +205,21 @@ info:
For example, if the `count` is 100 and the `limit` is 50, you can divide the `count` by the `limit` to get the number of pages: `100/50 = 2 pages`.
### Sort Order
The `order` field available on endpoints supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their `created_at` attribute by setting `order` to `created_at`:
```bash
curl "http://localhost:9000/list/products?order=created_at"
```
By default, the sort direction will be ascending. To change it to descending, pass a dash (`-`) before the attribute name. For example:
```bash
curl "http://localhost:9000/list/products?order=-created_at"
```
This sorts the products by their `created_at` attribute in the descending order.
license:
name: MIT
url: https://github.com/medusajs/medusa/blob/master/LICENSE

View File

@@ -66,7 +66,7 @@
color: var(--ifm-color-headers) !important;
}
.redocusaurus [data-section-id] > div:nth-child(2) h2, .redocusaurus [data-section-id] > div:nth-child(2) h3, .redocusaurus [data-section-id] > div:nth-child(2) h4 {
.redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h2, .redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h3, .redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h4 {
--ifm-color-headers: var(--medusa-text-on-color);
}