Search...
listReservations( )
Developer Preview
Retrieves a list of up to 100 reservations.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function listReservations(options: ListReservationsOptions): Promise<ListReservationsResponse>
listReservations Parameters
NAME
TYPE
DESCRIPTION
options
Optional
ListReservationsOptions
Options for listing the reservations.
Returns
Return Type:
Promise<
ListReservationsResponse
>NAME
TYPE
DESCRIPTION
pagingMetadata
CursorPagingMetadata
Metadata for the paginated results.
reservations
Array<
Reservation
>List of reservations.
Was this helpful?
List reservations with options (backend)
This function call requires elevation to get the necessary permissions.
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { reservations } from 'wix-table-reservations.v2';3import { elevate } from 'wix-auth';45/* Sample options value:6 * {7 * "startDateFrom" : new Date("2024-12-04T10:30:00Z"),8 * "startDateTo" : new Date("2024-12-04T17:30:00Z"),9 * "status" : "RESERVED"10 * }11 */1213export const myListReservationsFunction = webMethod(Permissions.Anyone, async (options) => {14 const elevatedListReservations = elevate(reservations.listReservations);1516 try {17 const retrievedReservations = await elevatedListReservations(options);1819 const createdDate = retrievedReservations.reservations[0]._createdDate;20 const status = retrievedReservations.reservations[0].status;2122 return retrievedReservations;23 } catch (error) {24 console.error(error);25 // Handle the error26 }27});2829/* Promise resolves to:30 * {31 * "reservations": [32 * {33 * "status": "RESERVED",34 * "source": "ONLINE",35 * "details": {36 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",37 * "tableIds": [38 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"39 * ],40 * "startDate": "2024-12-04T12:30:00.000Z",41 * "endDate": "2024-12-04T14:00:00.000Z",42 * "partySize": 243 * },44 * "revision": "1",45 * "migrationNotes": [],46 * "tablesWithReservationConflicts": [],47 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",48 * "_createdDate": "2024-01-22T07:25:51.008Z",49 * "_updatedDate": "2024-01-22T07:25:51.008Z"50 * },51 * {52 * "status": "RESERVED",53 * "source": "ONLINE",54 * "details": {55 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",56 * "tableIds": [57 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"58 * ],59 * "startDate": "2024-12-04T14:30:00.000Z",60 * "endDate": "2024-12-04T16:00:00.000Z",61 * "partySize": 262 * },63 * "revision": "1",64 * "migrationNotes": [],65 * "tablesWithReservationConflicts": [],66 * "_id": "3e09e2fb-0cc8-476e-9874-f134b3add055",67 * "_createdDate": "2024-01-22T07:33:10.651Z",68 * "_updatedDate": "2024-01-22T07:33:10.651Z"69 * },70 * {71 * "status": "RESERVED",72 * "source": "ONLINE",73 * "details": {74 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",75 * "tableIds": [76 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"77 * ],78 * "startDate": "2024-12-04T10:30:00.000Z",79 * "endDate": "2024-12-04T12:00:00.000Z",80 * "partySize": 281 * },82 * "revision": "1",83 * "migrationNotes": [],84 * "tablesWithReservationConflicts": [],85 * "_id": "98100e83-76cc-4791-87c6-4c6dd4fe9e22",86 * "_createdDate": "2024-01-22T07:32:31.548Z",87 * "_updatedDate": "2024-01-22T07:32:31.548Z"88 * }89 * ],90 * "pagingMetadata": {91 * "count": 3,92 * "cursors": {},93 * "hasNext": false94 * }95 * }96 */
List reservations with options (dashboard page)
This function requires additional permissions and can only be called without elevation from a dashboard page
Copy Code
1import { reservations } from 'wix-table-reservations.v2';23/* Sample options value:4 * {5 * "startDateFrom" : new Date("2024-12-04T10:30:00Z"),6 * "startDateTo" : new Date("2024-12-04T17:30:00Z"),7 * "status" : "RESERVED"8 * }9 */1011reservations.listReservations(options)12 .then((retrievedReservations) => {1314 const createdDate = retrievedReservations.reservations[0]._createdDate;15 const status = retrievedReservations.reservations[0].status;1617 console.log('Success! Retrieved reservations:', retrievedReservations);18 return retrievedReservations;19 })20 .catch((error) => {21 console.error(error);22 // Handle the error23 });2425 /* Promise resolves to:26 * {27 * "reservations": [28 * {29 * "status": "RESERVED",30 * "source": "ONLINE",31 * "details": {32 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",33 * "tableIds": [34 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"35 * ],36 * "startDate": "2024-12-04T12:30:00.000Z",37 * "endDate": "2024-12-04T14:00:00.000Z",38 * "partySize": 239 * },40 * "revision": "1",41 * "migrationNotes": [],42 * "tablesWithReservationConflicts": [],43 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",44 * "_createdDate": "2024-01-22T07:25:51.008Z",45 * "_updatedDate": "2024-01-22T07:25:51.008Z"46 * },47 * {48 * "status": "RESERVED",49 * "source": "ONLINE",50 * "details": {51 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",52 * "tableIds": [53 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"54 * ],55 * "startDate": "2024-12-04T14:30:00.000Z",56 * "endDate": "2024-12-04T16:00:00.000Z",57 * "partySize": 258 * },59 * "revision": "1",60 * "migrationNotes": [],61 * "tablesWithReservationConflicts": [],62 * "_id": "3e09e2fb-0cc8-476e-9874-f134b3add055",63 * "_createdDate": "2024-01-22T07:33:10.651Z",64 * "_updatedDate": "2024-01-22T07:33:10.651Z"65 * },66 * {67 * "status": "RESERVED",68 * "source": "ONLINE",69 * "details": {70 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",71 * "tableIds": [72 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"73 * ],74 * "startDate": "2024-12-04T10:30:00.000Z",75 * "endDate": "2024-12-04T12:00:00.000Z",76 * "partySize": 277 * },78 * "revision": "1",79 * "migrationNotes": [],80 * "tablesWithReservationConflicts": [],81 * "_id": "98100e83-76cc-4791-87c6-4c6dd4fe9e22",82 * "_createdDate": "2024-01-22T07:32:31.548Z",83 * "_updatedDate": "2024-01-22T07:32:31.548Z"84 * }85 * ],86 * "pagingMetadata": {87 * "count": 3,88 * "cursors": {},89 * "hasNext": false90 * }91 * }92 */93