www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx
import { CodeTabs, CodeTab, Table } from "docs-ui"
export const metadata = {
title: Links between Currency Module and Other Modules,
}
This document showcases the module links defined between the Currency Module and other Commerce Modules.
The Currency Module has the following links to other modules:
<Note title="Tip">Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.
</Note> <Table> <Table.Header> <Table.Row> <Table.HeaderCell> First Data Model </Table.HeaderCell> <Table.HeaderCell> Second Data Model </Table.HeaderCell> <Table.HeaderCell> Type </Table.HeaderCell> <Table.HeaderCell> Description </Table.HeaderCell> </Table.Row> </Table.Header> <Table.Body> <Table.Row> <Table.Cell> [StoreCurrency](/references/store/models/StoreCurrency) in [Store Module](../../store/page.mdx) </Table.Cell> <Table.Cell> [Currency](/references/currency/models/Currency) </Table.Cell> <Table.Cell> Read-only - has one </Table.Cell> <Table.Cell> [Learn more](#store-module) </Table.Cell> </Table.Row> </Table.Body> </Table> ---The Store Module has a Currency data model that stores the supported currencies of a store. However, these currencies don't hold all the details of a currency, such as its name or symbol.
Instead, Medusa defines a read-only link between the Store Module's StoreCurrency data model and the Currency Module's Currency data model. Because the link is read-only from the Store's side, you can only retrieve the details of a store's supported currencies, and not the other way around.
To retrieve the details of a store's currencies with Query, pass supported_currencies.currency.* in fields:
const { data: stores } = await query.graph({
entity: "store",
fields: [
"supported_currencies.currency.*",
],
})
// stores[0].supported_currencies[0].currency
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
// ...
const { data: stores } = useQueryGraphStep({
entity: "store",
fields: [
"supported_currencies.currency.*",
],
})
// stores[0].supported_currencies[0].currency