queryBookings( )

Creates a query to retrieve a list of bookings.


The queryBookings() function builds a query to retrieve a list of bookings and returns a BookingsQueryBuilder object.

The returned object contains the query definition which is typically used to run the query using the find() function.

You can refine the query by chaining BookingsQueryBuilder functions onto the query. BookingsQueryBuilder functions enable you to sort, filter, and control the results that queryBookings() returns.

The query runs with the following BookingsQueryBuilder defaults that you can override:

The functions that are chained to queryBookings() are applied in the order they are called. For example, if you sort on the _createdDate property in ascending order and then on the status property in descending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by status in descending order, per created date value.

The following BookingsQueryBuilder functions are supported for queryBookings(). For a full description of the Booking object, see the object returned for the items property in BookingsQueryResult.

_ideq()Query for a specific booking.
contactIdeq()Bookings made by the specified contact ID. eq("contactId","8711a950-74cc-4608-80fb-8f09df9cbbf4")
sessionIdeq(), hasSome()Bookings made to a given session or a list of sessions.
hasSome("sessionId","[193ZPR9ppP9emJUCLevcLf6orynNE45", "c8UhG9ppABemJUCLevcLf6orynNE98"] )
startTimege() , lt(), ascending(), descending()Bookings with a schedule or session start time (UTC) earlier than a given time, or at a given time or later.
ge("startTime", "2020-04-27T10:00:00.000Z")
endTimegt(), le()Bookings with a schedule or session end time (UTC) later than a given time, or at a given time or earlier.
gt("endTime", "2020-04-27T10:00:00.000Z")
statuseq(), hasSome()Bookings with a given status or a status that is in a given list of statuses.
_createdDatege(), lt(), ascending(), descending()Bookings created at a given date or later, or earlier than a given date.
lt("_createdDate", "2020-04-27T10:00:00.000Z")

You can only use one filter function for each property. If a property is used in more than one filter, only the first filter will work.


  • By default, queryBookings() retrieves only statuses of "CONFIRMED". To retrieve all booking statuses use a hasSome() filter with all of the statuses.
  • When using the queryBookings() function immediately following a change to your bookings, the data retrieved may not contain your most recent changes. See Wix-data and Eventual Consistency for more information. To solve this problem, you can use the setTimeout() function to delay querying for a number of seconds, following any changes to your bookings data.
  • Only users with Bookings Admin permissions can retrieve other customers' bookings. You can override the permissions by setting the suppressAuth options to true.


function queryBookings(): BookingsQueryBuilder

queryBookings Parameters

This function does not take any parameters.


Was this helpful?

List all bookings

Use a hasSome() filter to override the default and retrieve all booking statuses.

Copy Code
1import { bookings } from "wix-bookings-backend";
3export function queryBookings() {
4 return bookings
5 .queryBookings()
7 .find()
8 .then((queryResult) => {
9 return queryResult.items;
10 })
11 .catch((error) => {
12 return error;
13 });
Retrieve bookings that are pending approval, where the creation date is on or after December 20, 2020 at 10 am, and the start date of the session is before January 7, 2021 at 5 pm

Copy Code
1import { bookings } from "wix-bookings-backend";
3export function queryBookings() {
4 return bookings
5 .queryBookings()
6 .eq("status", "PENDING_APPROVAL")
7 .ge("_createdDate", "2020-12-20T10:00:00.000Z")
8 .lt("startTime", "2021-01-07T17:00:00.000Z")
9 .find()
10 .then((queryResult) => {
11 return queryResult.items;
12 })
13 .catch((error) => {
14 return error;
15 });