Returns the items that match the query.
The current page of items retrieved by the query.
The page size is defined by the limit()
function, can be retrieved using the pageSize
property, and
navigating through pages is done with the prev()
and
next()
functions.
When no items match the query, the items
array is empty.
import wixPricingPlansBackend from "wix-pricing-plans-backend";
// ...
wixPricingPlansBackend
.queryPublicPlans()
.find()
.then((results) => {
if (results.items.length > 0) {
const items = results.items; // see below
} else {
// handle case where no matching items found
}
})
.catch((error) => {
const queryError = error;
});
/* items:
* [
* {
* "plan": {
* "_id": "5269ddde-a3a6-7c32-abc1-fe8af8331097",
* "name": "Basic",
* "description": "This plan provides the basics.",
* "pricing": {
* "singlePaymentUnlimited": true,
* "price": {
* "value": "50",
* "currency": "USD"
* }
* },
* "primary": false,
* "_createdDate": "2021-01-01T15\:33\:34.860Z",
* "_updatedDate": "2021-01-14T10\:30\:30.870Z",
* "slug": "basic",
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "",
* "perks": [
* "Essentials only",
* "For beginners"
* ]
* }
* },
* {
* "plan": {
* "_id": "31c26520-a3a6-7c32-abc1-d4b11e509a92",
* "name": "Intermediate",
* "description": "This plan provides intermediate capabilities",
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 2
* },
* "price": {
* "value": "25",
* "currency": "USD"
* },
* "freeTrialDays": 3
* },
* "primary": false,
* "_createdDate": "2020-02-14T15\:33\:34.977Z",
* "_updatedDate": "2021-01-14T10\:30\:30.970Z",
* "slug": "intermediate",
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "",
* "perks": [
* "Cool templates you can reuse",
* "Includes the Basic plan"
* ]
* }
* },
* {
* "plan": {
* "_id": "6e01c2ae-b3b6-7a33-abc1-b7daf0fd125c",
* "name": "Advanced",
* "description": "This plan provides advanced capabilities",
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* },
* "cycleCount": 0
* },
* "price": {
* "value": "100",
* "currency": "USD"
* }
* },
* "primary": false,
* "_createdDate": "2020-12-14T15\:33\:35.677Z",
* "_updatedDate": "2021-01-14T11\:33\:11.677Z",
* "slug": "advanced",
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "perks": [
* "Extra utilities, plug-ins",
* "Includes the Intermediate Plan"
* ]
* }
* },
* {
* "plan": {
* "_id": "a7fff6ae-b3b6-7a33-abc1-2b9f8b39e6c5",
* "name": "Advanced VIP",
* "description": "This plan provides a lot of extras that are really cool in addition to the regular Advanced plan",
* "pricing": {
* "singlePaymentUnlimited": true,
* "price": {
* "value": "125",
* "currency": "USD"
* }
* },
* "primary": false,
* "_createdDate": "2021-01-14T15\:33\:35.782Z",
* "_updatedDate": "2021-01-14T15\:33\:35.782Z",
* "slug": "advanced-vip",
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "",
* "perks": [
* "Free beer and champagne sent to your home when you purchase the plan",
* "Discount on our merchandise",
* "Includes the Advanced plan"
* ]
* }
* }
* ]
*/
const resultLength = results.length; // 20
const resultPageSize = results.pageSize; // 50
Returns the query used to get the current results.
const resultQuery = results.query;
Returns the total number of items that match the query.
The totalCount
returns the total number of items that match the query,
not just the number of items in the current page.
const resultCount = results.totalCount; // 150
const resultPages = results.totalPages; // 3
Indicates if the query has more results.
function hasNext(): boolean;
const hasNext = results.hasNext(); // true
Indicates the query has previous results.
function hasPrev(): boolean;
const hasPrev = results.hasPrev(); // false
Retrieves the next page of query results.
The next()
function retrieves the next page of query results.
The page size is defined by the limit()
function, can be retrieved using the pageSize
property, and
navigating through pages is done with the prev()
and
next()
functions.
If items are added or removed between calls to next()
the values returned
by PublicPlansQueryResult
may change.
function next(): Promise<PublicPlansQueryResult>;
oldResults
.next()
.then((results) => {
const newResults = results;
const items = newResults.items;
const firstItem = items[0];
const totalCount = newResults.totalCount;
const pageSize = newResults.pageSize;
const currentPage = newResults.currentPage;
const totalPages = newResults.totalPages;
const hasNext = newResults.hasNext();
const hasPrev = newResults.hasPrev();
const length = newResults.length;
const query = newResults.query;
})
.catch((error) => {
const queryError = error;
});
Retrieves the previous page of query results.
The prev()
function retrieves the previous page of query results.
The page size is defined by the limit()
function, can be retrieved using the pageSize
property, and
navigating through pages is done with the prev()
and
next()
functions.
If items are added or removed between calls to prev()
the values returned
may change.
function prev(): Promise<PublicPlansQueryResult>;
oldResults
.prev()
.then((results) => {
const newResults = results;
const items = newResults.items;
const firstItem = items[0];
const totalCount = newResults.totalCount;
const pageSize = newResults.pageSize;
const currentPage = newResults.currentPage;
const totalPages = newResults.totalPages;
const hasNext = newResults.hasNext();
const hasPrev = newResults.hasPrev();
const length = newResults.length;
const query = newResults.query;
})
.catch((error) => {
const queryError = error;
});