Introduction

When you execute a query with the find() function, it returns a Promise that resolves to a ContactsQueryResult object. This object contains the items that match the query, information about the query itself, and functions for paging through the query results.

Did this help?

items


itemsArray<Contact>Read-only

Returns the items that match the query.

The current page of items retrieved by the query.

List of contacts.

Note: When no items match the query, the items array is empty.

To paginate your query results, use the ContactsQueryResult pagination properties and functions.

Perform a query and get the returned items from the result
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { contacts } from "wix-crm-backend"; export const getQueryResultItems = webMethod(Permissions.Anyone, () => { return contacts .queryContacts() .limit(5) .find() .then((results) => { if (results.items.length > 0) { return results.items; } else { console.log("No items found"); } }) .catch((error) => { console.error(error); }); }); /* items: * [ * { * "_id": "a52852d7-e0d6-484b-93fe-bffdb670f08f", * "_createdDate": "2021-03-30T20:18:06.874Z", * "_updatedDate": "2021-03-31T00:10:13.607Z", * "revision": 3, * "info": { * "name": { * "first": "Ari", * "last": "Thereyet" * }, * "picture": {}, * "emails": [ * { * "_id": "e6f2733e-32b8-4d99-95ce-7d2e63a39108", * "tag": "HOME", * "email": "ari.thereyet@example.com", * "primary": true * }, * { * "_id": "703f6faf-7d88-42ce-8e28-54f8d5f6e5e4", * "tag": "UNTAGGED", * "email": "ari.thereyet.appended.email@example.com", * "primary": false * } * ], * "phones": [ * { * "_id": "970380bb-57e0-4b3a-8f40-ccc93be1ab58", * "tag": "MOBILE", * "phone": "601-081-124", * "primary": true * } * ], * "labelKeys": [ * "custom.stale-lead" * ], * "extendedFields": { * "contacts.displayByLastName": "Thereyet Ari", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "emailSubscriptions.effectiveEmail": "ari.thereyet.appended.email@example.com", * "contacts.displayByFirstName": "Ari Thereyet" * } * }, * "lastActivity": { * "activityDate": "2021-03-30T20:18:06.872Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "ari.thereyet@example.com", * "phone": "601-081-124" * }, * "source": { * "sourceType": "WIX_APP" * } * }, * { * "_id": "bc0ae72b-3285-485b-b0ad-c32c769a4daf", * "_createdDate": "2021-03-30T13:12:39.650Z", * "_updatedDate": "2021-03-30T13:12:39.650Z", * "revision": 0, * "info": { * "name": { * "first": "Gene", * "last": "Lopez" * }, * "company": "Borer and Sons, Attorneys at Law", * "birthdate": "1981-11-02", * "jobTitle": "Senior Staff Attorney", * "locale": "en-us", * "picture": { * "image": "https://randomuser.me/api/portraits/men/0.jpg", * "imageProvider": "EXTERNAL" * }, * "emails": [ * { * "_id": "5bdcce4a-37c2-46ed-b49c-d562c6e3c4ce", * "tag": "HOME", * "email": "gene.lopez.at.home@example.com", * "primary": true * }, * { * "_id": "78e5f398-e148-448d-b490-7c0b7d2ab336", * "tag": "WORK", * "email": "gene.lopez@example.com", * "primary": false * } * ], * "phones": [ * { * "_id": "820e4640-ffe0-4980-a097-62a715e73135", * "tag": "MOBILE", * "countryCode": "US", * "phone": "(722)-138-3099", * "primary": true * }, * { * "_id": "8506549e-e4f8-42f6-b6fc-9db155b582ef", * "tag": "HOME", * "countryCode": "US", * "phone": "(704)-454-1233", * "e164Phone": "+17044541233", * "primary": false * } * ], * "addresses": [ * { * "address": { * "formatted": "9834 Bollinger Rd\nEl Cajon, WY 97766\nUS", * "location": { * "latitude": 84.1048, * "longitude": -116.8836 * }, * "city": "El Cajon", * "subdivision": "US-WY", * "country": "US", * "postalCode": "97766", * "streetAddress": { * "name": "Bollinger Rd", * "number": "9834", * "apt": "" * } * }, * "_id": "8532051f-91f2-42d9-9a97-9f2c39e64f7a", * "tag": "HOME" * } * ], * "labelKeys": [ * "custom.white-glove-treatment", * "contacts.contacted-me", * "custom.new-lead" * ], * "extendedFields": { * "contacts.displayByLastName": "Lopez Gene", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "custom.event-we-met-at": "LegalBigData", * "emailSubscriptions.effectiveEmail": "gene.lopez.at.home@example.com", * "contacts.displayByFirstName": "Gene Lopez" * } * }, * "lastActivity": { * "activityDate": "2021-03-30T13:12:39.649Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "gene.lopez.at.home@example.com", * "phone": "(722)-138-3099" * }, * "source": { * "sourceType": "OTHER" * } * }, * { * "_id": "41b1c8e7-5ddd-4186-ad85-269985d6b296", * "_createdDate": "2021-03-29T21:16:54.801Z", * "_updatedDate": "2021-03-30T20:14:16.256Z", * "revision": 3, * "info": { * "name": { * "first": "Renata", * "last": "Kirsten" * }, * "picture": {}, * "emails": [ * { * "_id": "500569e4-144d-4f25-83a1-4a59956b698d", * "tag": "UNTAGGED", * "email": "renata.kirsten@example.com", * "primary": true * } * ], * "phones": [ * { * "_id": "3ea63681-598a-45bc-88fb-97fefdfd5a74", * "tag": "UNTAGGED", * "phone": "0177-3234750", * "primary": true * } * ], * "addresses": [ * { * "address": { * "formatted": "6677 Schlossstraße\n48435 Wittenberg\nGermany", * "city": "Wittenberg", * "subdivision": "DE-TH", * "country": "DE", * "postalCode": "48435", * "addressLine1": "6677 Schlossstraße" * }, * "_id": "b36d1a2d-9a6b-48c3-a463-c8b116303e9f", * "tag": "SHIPPING" * }, * { * "address": { * "formatted": "6677 Schlossstraße\n48435 Wittenberg\nGermany", * "city": "Wittenberg", * "subdivision": "DE-TH", * "country": "DE", * "postalCode": "48435", * "addressLine1": "6677 Schlossstraße" * }, * "_id": "2a3fc791-cbad-4ecd-8bf6-8072b2793e3a", * "tag": "BILLING" * } * ], * "labelKeys": [ * "contacts.customers" * ], * "extendedFields": { * "contacts.displayByLastName": "Kirsten Renata", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "ecom.lastPurchaseDate": "2021-03-29T21:17:01.122Z", * "ecom.numOfPurchases": 1, * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "ecom.totalSpentAmount": 120, * "emailSubscriptions.effectiveEmail": "renata.kirsten@example.com", * "contacts.displayByFirstName": "Renata Kirsten", * "ecom.totalSpentCurrency": "ILS" * } * }, * "lastActivity": { * "activityDate": "2021-03-29T21:17:01.122Z", * "activityType": "ECOM_PURCHASE" * }, * "primaryInfo": { * "email": "renata.kirsten@example.com", * "phone": "0177-3234750" * }, * "source": { * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "sourceType": "WIX_STORES" * } * }, * { * "_id": "67bcea88-b748-4cc8-a584-bb991b6e5d82", * "_createdDate": "2021-03-29T21:06:53.976Z", * "_updatedDate": "2021-03-29T21:06:53.976Z", * "revision": 0, * "info": { * "name": { * "first": "Ljiljana", * "last": "Francois" * }, * "birthdate": "1981-09-13", * "jobTitle": "Creative Director", * "company": "Happy Mouse Productions", * "locale": "en-us", * "emails": [ * { * "_id": "c030ed4c-e127-4f02-8256-8984415e0321", * "tag": "MAIN", * "email": "ljiljana.francois@example.com", * "primary": true * } * ], * "picture": {}, * "extendedFields": { * "contacts.displayByLastName": "Francois Ljiljana", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "emailSubscriptions.effectiveEmail": "ljiljana.francois@example.com", * "contacts.displayByFirstName": "Ljiljana Francois" * } * }, * "lastActivity": { * "activityDate": "2021-03-29T21:06:53.975Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "ljiljana.francois@example.com" * }, * "source": { * "sourceType": "OTHER" * } * }, * { * "_id": "1626081c-3b3c-4b44-855b-1acb1122e080", * "_createdDate": "2021-03-29T20:51:21.216Z", * "_updatedDate": "2021-03-30T11:50:42.040Z", * "revision": 6, * "info": { * "name": { * "first": "Celine", * "last": "Rousseau" * }, * "locale": "en", * "picture": {}, * "emails": [ * { * "tag": "UNTAGGED", * "email": "celine.rousseau@example.com", * "primary": true * } * ], * "phones": [ * { * "tag": "UNTAGGED", * "phone": "0177-7912572", * "primary": true * } * ], * "addresses": [ * { * "address": { * "formatted": "2451Rue des Cuirassiers\n9502 Grosshöchstetten\nSwitzerland", * "city": "Grosshöchstetten", * "subdivision": "CH-VD", * "country": "CH", * "postalCode": "9502", * "addressLine1": "2451Rue des Cuirassiers" * }, * "tag": "SHIPPING" * }, * { * "address": { * "formatted": "2451Rue des Cuirassiers\n9502 Grosshöchstetten\nSwitzerland", * "city": "Grosshöchstetten", * "subdivision": "CH-VD", * "country": "CH", * "postalCode": "9502", * "addressLine1": "2451Rue des Cuirassiers" * }, * "tag": "BILLING" * }, * { * "address": { * "formatted": "Israel", * "country": "IL" * }, * "tag": "UNTAGGED" * } * ], * "labelKeys": [ * "contacts.customers" * ], * "extendedFields": { * "contacts.displayByLastName": "Rousseau Celine", * "emailSubscriptions.deliverabilityStatus": "BOUNCED", * "ecom.lastPurchaseDate": "2021-03-29T21:00:35.835Z", * "members.membershipStatus": "APPROVED", * "ecom.numOfPurchases": 2, * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "ecom.totalSpentAmount": 27.5, * "members.mobile": false, * "contacts.displayByFirstName": "Celine Rousseau", * "ecom.totalSpentCurrency": "ILS" * } * }, * "lastActivity": { * "activityDate": "2021-03-29T20:58:47.548Z", * "activityType": "MEMBER_STATUS_CHANGED" * }, * "primaryInfo": { * "email": "celine.rousseau@example.com", * "phone": "0177-7912572" * }, * "source": { * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "sourceType": "WIX_STORES" * } * } * ] */
Did this help?

length


lengthnumberRead-only

Returns the number of items in the current results page.

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.

JavaScript
let resultLength = results.length; // 20
Did this help?

pageSize


pageSizenumberRead-only

Returns the query page size.

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.

JavaScript
let resultPageSize = results.pageSize; // 50
Did this help?

query


queryContactsQueryBuilderRead-only

Returns the ContactsQueryBuilder object used to get the current results.

Use the query property to create and run a new query by chaining additional ContactsQueryBuilder functions to it.

JavaScript
let resultQuery = results.query;
Did this help?

hasNext( )


Indicates if the query has more results.

Method Declaration
Copy
function hasNext(): boolean;
Request
This method does not take any parameters
Returns
Return Type:boolean
JavaScript
let hasNext = results.hasNext(); // true
Did this help?