Search.../

items

Returns an array of sessions that match the query.

Description

The current page of sessions retrieved by the query.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no items match the query, the items array is empty.

Type:

Array<Session>Read Only
NAME
TYPE
DESCRIPTION
_id
string

Session ID.

scheduleId
string

ID of the schedule that the session belongs to.

scheduleOwnerId
string

ID of the resource or service that the session's schedule belongs to.

tags
Array<string>

Tags for the session. The value is inherited from the schedule and can be overridden unless the session is a recurring session.

notes
string

Additional information about the session. Notes are not supported for recurring sessions.

status
string

Session status.

One of:

  • "CONFIRMED" Default value.
  • "CANCELLED" The session was deleted.
recurringSessionId
string

ID of the recurring session if this session is an instance of a recurrence. Use this ID to update the recurrence and all of the instances.

type
string

Session type.

One of:

  • "EVENT" Reserved period of time on the schedule. For example, an appointment, class, course, or blocked time. Events are visible in the Dashboard in the Bookings app's Booking Calendar page.
  • "WORKING_HOURS" Placeholder for available time on a resource’s schedule.
recurrence
string

String representing a recurrence rule (RRULE) for a recurring session, as defined in iCalendar RFC 5545. If the session is an instance of a recurrence pattern, the instanceOfRecurrence property will contain the recurrence rule and this property will be empty. The RRULE defines a rule for repeating a session. Supported parameters are:

KeywordDescriptionSupported values
FREQThe frequency at which the session is recurs. Required.WEEKLY
INTERVALHow often, in terms of FREQ, the session recurs. Default is 1. Optional.
UNTILThe UTC end date and time of the recurrence. Optional.
BYDAYDay of the week when the event should recur. Required.One of: MO, TU, WE, TH, FR, SA, SU

For example, a session that repeats every second week on a Monday until January 7, 2022 at 8 AM: "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO;UNTIL=20220107T080000Z"

instanceOfRecurrence
string

String representing a recurrence rule (RRULE) if the session is an instance of a recurrence pattern. Empty when the session is not an instance of a recurrence rule, or if the session defines a recurrence pattern, and recurrence is not empty.

start
CalendarDateTime

An object specifying the start date and time of the session. If the session is a recurring session, start must contain a localDateTime.

end
CalendarDateTime

An object specifying the end date and time of the session. If the session is a recurring session, end must contain a localDateTime.

Was this helpful?

Perform a query and get the session items from the result

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3// ...
4sessions.querySessions()
5 .ge("end.timestamp", "2021-01-01T00:00:00.000Z")
6 .lt("start.timestamp", "2021-05-01T00:00:00.000Z")
7 .limit(3)
8 .find()
9 .then((results) => {
10 if (results.items.length > 0) {
11 const items = results.items; // see below
12 } else {
13 // handle case where no matching items found
14 }
15 })
16 .catch((error) => {
17 console.error(error);
18 });
19
20
21 /* items:
22 * [
23 * {
24 * "end": {
25 * "localDateTime": {
26 * "year": 2021,
27 * "monthOfYear": 1,
28 * "dayOfMonth": 1,
29 * "hourOfDay": 11,
30 * "minutesOfHour": 0
31 * },
32 * "timestamp": "2021-01-01T09:00:00.000Z"
33 * },
34 * "_id": "193Z...gIR",
35 * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR",
36 * "notes": "",
37 * "recurringSessionId": "53616b1f0c3c45a1b282675acd248179-44539bfb63ae496693109b6cb3a65a65",
38 * "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
39 * "scheduleOwnerId": "b71df756-309f-468e-aec2-f82b9a9a9441",
40 * "start": {
41 * "localDateTime": {
42 * "year": 2021,
43 * "monthOfYear": 1,
44 * "dayOfMonth": 1,
45 * "hourOfDay": 10,
46 * "minutesOfHour": 0
47 * },
48 * "timestamp": "2021-01-01T08:00:00.000Z"
49 * },
50 * "status": "CONFIRMED",
51 * "tags": [
52 * "GROUP"
53 * ],
54 * "type": "EVENT"
55 * },
56 * {
57 * "end": {
58 * "localDateTime": {
59 * "year": 2021,
60 * "monthOfYear": 1,
61 * "dayOfMonth": 4,
62 * "hourOfDay": 18,
63 * "minutesOfHour": 0
64 * },
65 * "timestamp": "2021-01-04T16:00:00.000Z"
66 * },
67 * "_id": "4jO...deK",
68 * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR",
69 * "notes": "",
70 * "recurringSessionId": "9299760d8a4a4f89b3481fc611f4be17-ecc4a5932acb4b7bb8c27c6ffb57fd49",
71 * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17",
72 * "scheduleOwnerId": "e6b6108c-92bc-462b-937c-dab386909fd2",
73 * "start": {
74 * "localDateTime": {
75 * "year": 2021,
76 * "monthOfYear": 1,
77 * "dayOfMonth": 4,
78 * "hourOfDay": 10,
79 * "minutesOfHour": 0
80 * },
81 * "timestamp": "2021-01-04T08:00:00.000Z"
82 * },
83 * "status": "CONFIRMED",
84 * "tags": [],
85 * "type": "WORKING_HOURS"
86 * },
87 * {
88 * "end": {
89 * "localDateTime": {
90 * "year": 2021,
91 * "monthOfYear": 1,
92 * "dayOfMonth": 6,
93 * "hourOfDay": 18,
94 * "minutesOfHour": 0
95 * },
96 * "timestamp": "2021-01-06T16:00:00.000Z"
97 * },
98 * "_id": "4jO...Wwv",
99 * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR",
100 * "notes": "",
101 * "recurringSessionId": "9299760d8a4a4f89b3481fc611f4be17-3d6b38529f544674a4976eca75e584ca",
102 * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17",
103 * "scheduleOwnerId": "e6b6108c-92bc-462b-937c-dab386909fd2",
104 * "start": {
105 * "localDateTime": {
106 * "year": 2021,
107 * "monthOfYear": 1,
108 * "dayOfMonth": 6,
109 * "hourOfDay": 10,
110 * "minutesOfHour": 0
111 * },
112 * "timestamp": "2021-01-06T08:00:00.000Z"
113 * },
114 * "status": "CONFIRMED",
115 * "tags": [],
116 * "type": "WORKING_HOURS"
117 * }
118 * ]
119 */
Perform a query for recurring sessions and get the session items from the result

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3// ...
4sessions.querySessions()
5 .ge("end.timestamp", "2021-01-01T00:00:00.000Z")
6 .lt("start.timestamp", "2021-05-01T00:00:00.000Z")
7 .eq("scheduleId", "aec380c0-ca2c-43c2-98f4-9aebbd3276f3")
8 .ne("recurrence",null)
9 .limit(5)
10 .find()
11 .then((results) => {
12 if (results.items.length > 0) {
13 const items = results.items; // see below
14 } else {
15 // handle case where no matching items found
16 }
17 })
18 .catch((error) => {
19 console.error(error);
20 });
21
22
23 /*
24 * items:
25 * [
26 * {
27 *
28 * "_id": "aec380c0ca2c43c298f49aebbd3276f3-7c4fc7d98139444bbbc93aed0ac7e8ca",
29 * "notes": "",
30 * "recurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=WE;UNTIL=20220101T000000Z",
31 * "scheduleId": "aec380c0-ca2c-43c2-98f4-9aebbd3276f3",
32 * "scheduleOwnerId": "2a843db6-cb3f-4c96-90b8-f2f6e0055cae",
33 * "start": {
34 * "localDateTime": {
35 * "year": 2021,
36 * "monthOfYear": 3,
37 * "dayOfMonth": 1,
38 * "hourOfDay": 10,
39 * "minutesOfHour": 0
40 * }
41 * },
42 * "end": {
43 * "localDateTime": {
44 * "year": 2021,
45 * "monthOfYear": 3,
46 * "dayOfMonth": 1,
47 * "hourOfDay": 16,
48 * "minutesOfHour": 0
49 * }
50 * },
51 * "status": "CONFIRMED",
52 * "tags": [],
53 * "type": "WORKING_HOURS"
54 * },
55 * {
56 *
57 * "_id": "aec380c0ca2c43c298f49aebbd3276f3-316ff0991aa2417aaed137e1c051d8c6",
58 * "notes": "",
59 * "recurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO;UNTIL=20220101T000000Z",
60 * "scheduleId": "aec380c0-ca2c-43c2-98f4-9aebbd3276f3",
61 * "scheduleOwnerId": "2a843db6-cb3f-4c96-90b8-f2f6e0055cae",
62 * "start": {
63 * "localDateTime": {
64 * "year": 2021,
65 * "monthOfYear": 3,
66 * "dayOfMonth": 1,
67 * "hourOfDay": 10,
68 * "minutesOfHour": 0
69 * }
70 * },
71 * "end": {
72 * "localDateTime": {
73 * "year": 2021,
74 * "monthOfYear": 3,
75 * "dayOfMonth": 1,
76 * "hourOfDay": 16,
77 * "minutesOfHour": 0
78 * }
79 * },
80 * "status": "CONFIRMED",
81 * "tags": [],
82 * "type": "WORKING_HOURS"
83 * }
84 * ]
85 */