Search...
ascending( )
Adds a sort to a query, sorting by the specified properties in ascending order.
Description
The ascending()
function refines a ExtendedFieldsQueryBuilder
to sort in ascending order of
the specified properties. If you specify more than one property,
ascending()
sorts the results in ascending 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 ascending(propertyName: ...string): ExtendedFieldsQueryBuilder
ascending Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The properties used in the sort.
Supported properties:
_createdDate
_updatedDate
displayName
Returns
A ExtendedFieldsQueryBuilder
object that contains the refined query.
Return Type:
Was this helpful?
Add an
ascending
sort to a queryCopy Code
1const query = contacts.queryExtendedFields().descending("_createdDate");
Create a query, add an
ascending
sort, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myqueryExtendedFieldsFunction = webMethod(Permissions.Anyone, () => {56 return contacts.queryExtendedFields()7 .ascending("_createdDate")8 .find()9 .then((results) => {10 if (results.items.length > 0) {11 const items = results.items;12 const firstItem = items[0];13 const pageSize = results.pageSize;14 const hasNext = results.hasNext();15 const hasPrev = results.hasPrev();16 const length = results.length;17 const query = results.query;1819 return items;20 } else {21 // Handle case where no matching items found22 }23 })24 .catch((error) => {25 console.error(error);26 })2728});