Files
medusa-store/www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx
Shahed Nasser ebca8fed28 docs: revise commerce modules overview pages (#10738)
* revise API Key Module overview

* revise auth module

* support ref sidebar items

* remove examples

* revise cart module

* revise currency

* revise customer module

* revise fulfillment module

* revise inventory module

* revise order module

* revise payment

* revise pricing module

* revise product module

* revise promotion module

* revise region module

* revise sales channel module

* revise stock location module

* revise store module

* revise tax module

* revise user module

* lint content + fix snippets
2024-12-26 10:32:16 +02:00

69 lines
2.0 KiB
Plaintext

import { CodeTabs, CodeTab } from "docs-ui"
export const metadata = {
title: `Links between Currency Module and Other Modules`,
}
# {metadata.title}
This document showcases the module links defined between the Currency Module and other commerce modules.
## Summary
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>
- [`Currency` data model of Store Module \<\> `Currency` data model of Currency Module](#store-module). (Read-only).
---
## Store Module
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 Currency Module's `Currency` data model and the [Store Module](../../store/page.mdx)'s `Currency` data model. This means you can retrieve the details of a store's supported currencies, but you don't manage the links in a pivot table in the database. The currencies of a store are determined by the `currency_code` of the `Currency` data model in the Store Module.
### Retrieve with Query
To retrieve the details of a store's currencies with [Query](!docs!/learn/fundamentals/module-links/query), pass `supported_currencies.currency.*` in `fields`:
<CodeTabs group="relation-query">
<CodeTab label="query.graph" value="method">
```ts
const { data: stores } = await query.graph({
entity: "store",
fields: [
"supported_currencies.currency.*",
],
})
// stores.supported_currencies
```
</CodeTab>
<CodeTab label="useQueryGraphStep" value="step">
```ts
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
// ...
const { data: stores } = useQueryGraphStep({
entity: "store",
fields: [
"supported_currencies.currency.*",
],
})
// stores.supported_currencies
```
</CodeTab>
</CodeTabs>