listAndCountMoneyAmounts - Pricing Module Reference
BetaThis documentation provides a reference to the listAndCountMoneyAmounts method. This belongs to the Pricing Module.
This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters.
Example
To retrieve a list of money amounts using their IDs:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
const pricingService = await initializePricingModule()
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
{
id: moneyAmountIds
}
)
// do something with the money amounts or return them
}
To specify relations that should be retrieved within the money amounts:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
const pricingService = await initializePricingModule()
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
{
id: moneyAmountIds
},
{
relations: ["currency"]
}
)
// do something with the money amounts or return them
}
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
{
id: moneyAmountIds
},
{
relations: ["currency"],
skip,
take
}
)
// do something with the money amounts or return them
}
You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
{
$and: [
{
id: moneyAmountIds
},
{
currency_code: currencyCode
}
]
},
{
relations: ["currency"],
skip,
take
}
)
// do something with the money amounts or return them
}
Parameters
filtersFilterableMoneyAmountPropsThe filters to apply on the retrieved money amounts.
filtersFilterableMoneyAmountPropsconfigFindConfig<MoneyAmountDTO>The configurations determining how the money amounts are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a money amount.
configFindConfig<MoneyAmountDTO>select or relations, accept the attributes or relations associated with a money amount.sharedContextContextA context used to share resources, such as transaction manager, between the application and the module.
sharedContextContextReturns
The list of money amounts along with their total count.
Was this section helpful?