Search.../

ascending( )

Adds a sort to a query, sorting by the specified properties in ascending order.

Description

The ascending() function refines a PublicPlansQueryBuilder 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. When sorting, ascending order is: numbers, followed by symbols, and then letters.

Syntax

function ascending(propertyName: ...string): PublicPlansQueryBuilder

ascending Parameters

NAME
TYPE
DESCRIPTION
propertyName
string

The properties used in the sort.

Supported properties:

  • primary
  • slug
  • _createdDate
  • _updatedDate

Returns

A PublicPlansQueryBuilder object representing the refined query.

Was this helpful?

Add an ascending sort to a query

Copy Code
1const query = wixPricingPlansBackend.queryPublicPlans().ascending("_createdDate");
Create a query, add an ascending sort, and run it

Copy Code
1import wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3// ...
4
5wixPricingPlansBackend.queryPublicPlans()
6 .ascending("_createdDate")
7 .find()
8 .then((results) => {
9 if (results.items.length > 0) {
10 const items = results.items;
11 const firstItem = items[0];
12 const totalCount = results.totalCount;
13 const pageSize = results.pageSize;
14 const currentPage = results.currentPage;
15 const totalPages = results.totalPages;
16 const hasNext = results.hasNext();
17 const hasPrev = results.hasPrev();
18 const length = results.length;
19 const query = results.query;
20 } else {
21 // handle case where no matching items found
22 }
23 })
24 .catch((error) => {
25 const queryError = error;
26 });