listAndCountCurrencies - Pricing Module Reference
BetaThis documentation provides a reference to the listAndCountCurrencies method. This belongs to the Pricing Module.
This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters.
Example
To retrieve a list of currencies using their codes:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveCurrencies (codes: string[]) {
const pricingService = await initializePricingModule()
const [currencies, count] = await pricingService.listAndCountCurrencies(
{
code: codes
},
)
// do something with the currencies or return them
}
To specify attributes that should be retrieved within the money amounts:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveCurrencies (codes: string[]) {
const pricingService = await initializePricingModule()
const [currencies, count] = await pricingService.listAndCountCurrencies(
{
code: codes
},
{
select: ["symbol_native"]
}
)
// do something with the currencies 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 retrieveCurrencies (codes: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()
const [currencies, count] = await pricingService.listAndCountCurrencies(
{
code: codes
},
{
select: ["symbol_native"],
skip,
take
}
)
// do something with the currencies or return them
}
Parameters
filtersFilterableCurrencyPropsThe filters to apply on the retrieved currencies.
filtersFilterableCurrencyPropsconfigFindConfig<CurrencyDTO>The configurations determining how the currencies are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a currency.
configFindConfig<CurrencyDTO>select or relations, accept the attributes or relations associated with a currency.sharedContextContextA context used to share resources, such as transaction manager, between the application and the module.
sharedContextContextReturns
The list of currencies along with the total count.
Was this section helpful?