The WixBookingsQueryBuilder
functions enable you to run, sort, filter, and control
which results a query returns.
Typically, you build a query using any of the Bookings query functions,
refine the query by chaining WixBookingsQueryBuilder
functions, and then execute the
query by chaining one of the following: find()
or count()
.
For example, the following code queries all bookings of the customer with the specified contact ID and logs the first 5 results to the console, sorted in ascending order by the sessions' start times:
import wixBookingsBackend from "wix-bookings-backend";
wixBookingsBackend.queryBookings
.eq("contactId", "2cb1846f-0c7a-4c39-8736-349236cfab40")
.ascending("startTime")
.limit(5)
.find()
.then((results) => {
console.log(results.items);
});