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 totrue
.
Syntax
function find([options: AuthOptions]): Promise<ContactsQueryResult>
find Parameters
NAME
TYPE
DESCRIPTION
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?
1const queryResults = contacts.queryContacts().find();
find
on a query1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {56 return contacts.queryContacts()7 .find({8 suppressAuth: false9 })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;1920 return items;21 } else {22 // Handle case where no matching items found23 }24 })25 .catch((error) => {26 console.error(error);27 });2829});