Search...
descending( )
Adds a sort to a query, sorting by the specified properties in descending order.
Description
The descending()
function refines a CreateRequestsQueryBuilder
to sort in descending 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 before"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): CreateRequestsQueryBuilder
descending Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The properties used in the sort.
Supported property:
_createdDate
Returns
A CreateRequestsQueryBuilder
object representing the refined query.
Return Type:
Was this helpful?
Add a
descending
sort to a queryCopy Code
1const query = createRequests.queryCreateRequests().descending("_createdDate");
Create a query, add a
descending
sort, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { createRequests } from 'wix-groups-backend';34export const myQueryCreateRequestsFunction = webMethod(Permissions.Anyone, () => {5 return createRequests.queryCreateRequests()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 totalPages = results.totalPages;14 const totalCount = results.totalCount;15 const currentPage = results.currentPage();16 const next = results.next();17 const previous = results.prev();18 const hasNext = results.hasNext();19 const hasPrev = results.hasPrev();20 const length = results.length;2122 return items;23 } else {24 // Handle case where no matching items found25 }26 })27 .catch((error) => {28 console.error(error);29 })3031});