Introduction
The ContactsQueryBuilder
functions enable you to run, sort, filter, and control
which results a query returns.
Typically, you build a query using the queryContacts()
function,
refine the query by chaining ContactsQueryBuilder
functions, and then execute the
query by chaining the find()
function.
For example, the following code returns the first 5 contacts who work at Wix and sorts them by last name in ascending order:
javascript | Copy Codeimport { contacts } from 'wix-crm-backend';contacts.queryContacts().eq("info.companyName", "Wix").ascending("info.name.lastName").limit(5).find().then( (results) => {return results.items;});
Note: Only visitors with Manage Contacts permissions can query contacts. You can override the permissions by setting the
suppressAuth
option totrue
in thefind()
function.
Was this helpful?