Search...
descending( )
Adds a sort to a query, sorting by the specified properties in descending order.
Description
The descending()
function refines a LabelsQueryBuilder
to sort in ascending order of
the specified properties. If you specify more than one property,
descending()
sorts the results in descending order by each property in the
order they are listed.
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 as a String, that value will be sorted alphabetically and not numerically. Items that do not have a value for the specified sort property are ranked lowest.
Syntax
function descending(propertyName: ...string): LabelsQueryBuilder
descending Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The properties used in the sort.
Supported properties:
_createdDate
_updatedDate
displayName
Was this helpful?
Add an
descending
sort to a queryCopy Code
1const query = contacts.queryLabels().descending("_createdDate");
Create a query, add an
descending
sort, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myqueryLabelsFunction = webMethod(Permissions.Anyone, () => {5 return contacts.queryLabels()6 .descending("_createdDate")7 .find()8 .then((results) => {9 if (results.items.length > 0) {10 const items = results.items;11 const firstItem = items[0];12 const pageSize = results.pageSize;13 const hasNext = results.hasNext();14 const hasPrev = results.hasPrev();15 const length = results.length;16 const query = results.query;1718 return items;19 } else {20 // Handle case where no matching items found21 }22 })23 .catch((error) => {24 console.error(error);25 })2627});