Search...
ascending( )
Adds a sort to a query, sorting by the specified properties in ascending order.
Description
The ascending()
function refines a GroupsQueryBuilder
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): GroupsQueryBuilder
ascending Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The properties used in the sort.
Supported properties:
_createdDate
name
memberCount
lastActivityDate
Was this helpful?
Add an
ascending
sort to a queryCopy Code
1const query = groups.queryGroups().ascending("name");
Create a query, add an
ascending
sort, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { groups } from 'wix-groups-backend';34export const myQueryGroupsFunction = webMethod(Permissions.Anyone, () => {5 return groups.queryGroups()6 .ascending("name")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});