When you execute a query with the find()
function, it returns a Promise that resolves to a ExtendedFieldsQueryResult
object.
This object contains the items that match the query, information about the
query itself, and functions for paging through the query results.
Returns the items that match the query.
The current page of items retrieved by the query.
List of extended fields.
Note: When no items match the query, the items array is empty.
To paginate your query results, use the ExtendedFieldsQueryResult
pagination properties and functions.
import { Permissions, webMethod } from "wix-web-module";
import { contacts } from "wix-crm-backend";
export const getQueryResultItems = webMethod(Permissions.Anyone, () => {
return contacts
.queryExtendedFields()
.limit(10)
.find()
.then((results) => {
if (results.items.length > 0) {
return results.items;
} else {
console.log("No items found");
}
})
.catch((error) => {
console.error(error);
});
});
/* items:
* [
* {
* "_createdDate": "2021-03-30T12:41:13.000Z",
* "dataType": "TEXT",
* "displayName": "Event we met at",
* "fieldType": "USER_DEFINED",
* "key": "custom.event-we-met-at",
* "namespace": "custom",
* "_updatedDate": "2021-03-30T12:41:13.000Z"
* },
* {
* "_createdDate": "2021-01-19T23:18:17.000Z",
* "dataType": "DATE",
* "displayName": "Last Contacted",
* "fieldType": "USER_DEFINED",
* "key": "custom.last-contacted",
* "namespace": "custom",
* "_updatedDate": "2021-01-19T23:18:17.000Z"
* },
* {
* "dataType": "TEXT",
* "description": "Display name starting with last name (read only)",
* "displayName": "Display Name (start with last)",
* "fieldType": "SYSTEM",
* "key": "contacts.displayByLastName",
* "namespace": "contacts"
* },
* {
* "dataType": "TEXT",
* "description": "Vat ID for Wix Invoices",
* "displayName": "VAT ID",
* "fieldType": "SYSTEM",
* "key": "invoices.vatId",
* "namespace": "invoices"
* },
* {
* "dataType": "TEXT",
* "description": "APPROVED/DENIED/PENDING/INACTIVE (read only)",
* "displayName": "Membership Status",
* "fieldType": "SYSTEM",
* "key": "members.membershipStatus",
* "namespace": "members"
* },
* {
* "dataType": "NUMBER",
* "description": "Wix Stores purchase count (read only)",
* "displayName": "# of Purchases",
* "fieldType": "SYSTEM",
* "key": "ecom.numOfPurchases",
* "namespace": "ecom"
* },
* {
* "dataType": "NUMBER",
* "description": "Wix Stores aggregated spent amount (read only)",
* "displayName": "Total Spent Amount",
* "fieldType": "SYSTEM",
* "key": "ecom.totalSpentAmount",
* "namespace": "ecom"
* },
* {
* "dataType": "TEXT",
* "description": "Wix Stores currency code (read only)",
* "displayName": "Total Spent Currency",
* "fieldType": "SYSTEM",
* "key": "ecom.totalSpentCurrency",
* "namespace": "ecom"
* },
* {
* "dataType": "DATE",
* "description": "Wix Stores last purchase date (read only)",
* "displayName": "Last Purchase Date",
* "fieldType": "SYSTEM",
* "key": "ecom.lastPurchaseDate",
* "namespace": "ecom"
* },
* {
* "dataType": "TEXT",
* "description": "SUBSCRIBED/UNSUBSCRIBED/NOT_SET/PENDING (read only)",
* "displayName": "Effective Subscription Status",
* "fieldType": "SYSTEM",
* "key": "emailSubscriptions.subscriptionStatus",
* "namespace": "emailSubscriptions"
* },
* {
* "dataType": "TEXT",
* "description": "VALID/BOUNCED/SPAM_COMPLAINT/INACTIVE (read only)",
* "displayName": "Effective Deliverability Status",
* "fieldType": "SYSTEM",
* "key": "emailSubscriptions.deliverabilityStatus",
* "namespace": "emailSubscriptions"
* }
* ]
*/
let resultLength = results.length; // 20
let resultPageSize = results.pageSize; // 50
Returns the ExtendedFieldsQueryBuilder
object used to get the current results.
Use the query
property to create and run a new query
by chaining additional ExtendedFieldsQueryBuilder
functions to it.
You can filter only on properties that have not not already been used in the previous query.
let resultQuery = results.query;
Indicates if the query has more results.
function hasNext(): boolean;
let hasNext = results.hasNext(); // true
Indicates if the query has previous results.
function hasPrev(): boolean;
let hasPrev = results.hasPrev(); // false