Returns the bookings that match the query.
The find()
function returns a Promise that resolves to the results found
by the query and some information about the results. The Promise is
rejected if find()
is called with incorrect permissions or if any of the
functions used to refine the query are invalid.
Note: Only users with Bookings Admin permissions can view participant information in a session query. You can override the permissions by setting the suppressAuth
options to true
.
function find(options: QueryOptions): Promise<SessionQueryResult>;
Options to use when performing a query.
import { sessions } from "wix-bookings-backend";
// ...
sessions
.querySessions()
.ge("end.timestamp", "2021-01-01T00:00:00.000Z")
.lt("start.timestamp", "2021-05-01T00:00:00.000Z")
.find()
.then((results) => {
if (results.items.length > 0) {
const items = results.items;
const firstItem = items[0];
const totalCount = results.totalCount;
const pageSize = results.pageSize;
const currentPage = results.currentPage;
const totalPages = results.totalPages;
const hasNext = results.hasNext();
const hasPrev = results.hasPrev();
const length = results.length;
const query = results.query;
} else {
// handle case where no matching items found
}
})
.catch((error) => {
console.error(error);
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.