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:
import { contacts } from "wix-crm-backend";
contacts
.queryContacts()
.eq("info.company", "Wix")
.ascending("info.name.last")
.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 to true
in the find()
function.