Search.../

find( )

Returns the items that match the query.

Description

The find() function returns a Promise that resolves to the results found by the query and some information about the results. The Promise is rejected if find() is called with incorrect permissions or if any of the functions used to refine the query are invalid.

Note: Only visitors with Manage Contacts permissions can query contacts. You can override the permissions by setting the suppressAuth option to true.

Syntax

function find([options: AuthOptions]): Promise<ContactsQueryResult>

find Parameters

NAME
TYPE
DESCRIPTION
options
Optional
AuthOptions

Authorization options.

Returns

Fulfilled - The results of a contacts query, containing the retrieved items. 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.

Return Type:

Was this helpful?

Run a query with no filters

Copy Code
1const queryResults = contacts.queryContacts().find();
Perform a find on a query

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {
5
6 return contacts.queryContacts()
7 .find({
8 suppressAuth: false
9 })
10 .then((results) => {
11 if (results.items.length > 0) {
12 const items = results.items;
13 const firstItem = items[0];
14 const pageSize = results.pageSize;
15 const hasNext = results.hasNext();
16 const hasPrev = results.hasPrev();
17 const length = results.length;
18 const query = results.query;
19
20 return items;
21 } else {
22 // Handle case where no matching items found
23 }
24 })
25 .catch((error) => {
26 console.error(error);
27 });
28
29});