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.

PropertyFiltersDescription
_ideq()Query for a specific booking. eq("_id","46ce4cd4-46ff-4aa7-9cc0-02fd4f0f3209")
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. hasSome("status", ["CONFIRMED", "PENDING_APPROVAL","CANCELED"])
_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.

Notes:

  • 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.
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Was this helpful?
Yes
No