Search.../

find( )

Returns the bookings that match the query.

Description

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.

Syntax

function find([options: QueryOptions]): Promise<SessionQueryResult>

find Parameters

NAME
TYPE
DESCRIPTION
options
Optional
QueryOptions

Options to use when performing a query.

Returns

Fulfilled - A Promise that resolves to the results of the query. Rejected - Error that caused the query to fail.

Return Type:

Was this helpful?

Perform a find on a query

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3// ...
4
5sessions.querySessions()
6 .ge("end.timestamp", "2021-01-01T00:00:00.000Z")
7 .lt("start.timestamp", "2021-05-01T00:00:00.000Z")
8 .find()
9 .then((results) => {
10 if (results.items.length > 0) {
11 const items = results.items;
12 const firstItem = items[0];
13 const totalCount = results.totalCount;
14 const pageSize = results.pageSize;
15 const currentPage = results.currentPage;
16 const totalPages = results.totalPages;
17 const hasNext = results.hasNext();
18 const hasPrev = results.hasPrev();
19 const length = results.length;
20 const query = results.query;
21 } else {
22 // handle case where no matching items found
23 }
24 })
25 .catch((error) => {
26 console.error(error);
27 });
Perform a find on a query using options

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3// ...
4const options = {
5 "suppressAuth": true
6};
7
8sessions.querySessions()
9 .ge("end.timestamp", "2021-01-01T00:00:00.000Z")
10 .lt("start.timestamp", "2021-05-01T00:00:00.000Z")
11 .find(options)
12 .then((results) => {
13 if (results.items.length > 0) {
14 const items = results.items;
15 const firstItem = items[0];
16 const totalCount = results.totalCount;
17 const pageSize = results.pageSize;
18 const currentPage = results.currentPage;
19 const totalPages = results.totalPages;
20 const hasNext = results.hasNext();
21 const hasPrev = results.hasPrev();
22 const length = results.length;
23 const query = results.query;
24 } else {
25 // handle case where no matching items found
26 }
27 })
28 .catch((error) => {
29 console.error(error);
30 });