Search...
descending( )
Adds a sort to a query, sorting by the specified properties in descending order.
Description
The descending()
function refines a TagsQueryBuilder
to sort by the value of propertyName
in descending order.
You can specify multiple properties for sorting in descending order by passing each property name as an additional argument. descending()
sorts the results in the order the properties are passed.
You can sort the following types:
- Number: Sorts numerically.
- Date: Sorts by date and time.
- String: Sorts lexicographically, so
'abc'
comes after'XYZ'
.
If a property contains a number stored as a string (for example, '0'
), that value is sorted alphabetically and not numerically. If a property doesn't have a value, that value is ranked lowest.
Authorization
Request
This endpoint does not take any parameters
Response Object
Returns an empty object.
Status/Error Codes
Was this helpful?
Add a
descending
sort to a queryCopy Code
1const query = tags.queryTags.descending('label');2
Create a query, add a
descending
sort, and run itCopy Code
1import { tags } from 'wix-blog-backend';23export async function myQueryFunction() {4 const results = await tags.queryTags().descending('label').find();56 if (results.items.length > 0) {7 const items = results.items;8 const firstItem = items[0];9 const pageSize = results.pageSize;10 const hasNext = results.hasNext();11 const hasPrev = results.hasPrev();12 const length = results.length;13 const query = results.query;1415 return items;16 } else {17 // Handle if no matching items found18 }19}20