Skip to main content
Skip to main content

listReservationItems - Inventory Module Reference

This documentation provides a reference to the listReservationItems method. This belongs to the Inventory Module.

This method is used to retrieve a paginated list of reservation items along with the total count of available reservation items satisfying the provided filters.

Example

To retrieve a list of reservation items using their IDs:

import { 
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
})

// do something with the reservation items or return them
}

To specify relations that should be retrieved within the reservation items:

import { 
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
}, {
relations: ["inventory_item"]
})

// do something with the reservation items or return them
}

By default, only the first 10 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

import { 
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
}, {
relations: ["inventory_item"],
skip,
take
})

// do something with the reservation items or return them
}

Parameters

The filters to apply on the retrieved reservation items.
The configurations determining how the reservation items are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a reservation item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<[ReservationItemDTO[], number]>Required
The list of reservation items along with the total count.
Was this section helpful?