|
1
|
--- |
|
2
|
products: |
|
3
|
- currency |
|
4
|
--- |
|
5
|
|
|
6
|
import { CodeTabs, CodeTab, Table, Prerequisites } from "docs-ui" |
|
7
|
|
|
8
|
export const metadata = { |
|
9
|
title: `Links between Store Module and Other Modules`, |
|
10
|
} |
|
11
|
|
|
12
|
# {metadata.title} |
|
13
|
|
|
14
|
This document showcases the module links defined between the Store Module and other Commerce Modules. |
|
15
|
|
|
16
|
## Summary |
|
17
|
|
|
18
|
The Store Module has the following links to other modules: |
|
19
|
|
|
20
|
<Note title="Tip"> |
|
21
|
|
|
22
|
Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database. |
|
23
|
|
|
24
|
</Note> |
|
25
|
|
|
26
|
<Table> |
|
27
|
<Table.Header> |
|
28
|
<Table.Row> |
|
29
|
<Table.HeaderCell> |
|
30
|
First Data Model |
|
31
|
</Table.HeaderCell> |
|
32
|
<Table.HeaderCell> |
|
33
|
Second Data Model |
|
34
|
</Table.HeaderCell> |
|
35
|
<Table.HeaderCell> |
|
36
|
Type |
|
37
|
</Table.HeaderCell> |
|
38
|
<Table.HeaderCell> |
|
39
|
Description |
|
40
|
</Table.HeaderCell> |
|
41
|
</Table.Row> |
|
42
|
</Table.Header> |
|
43
|
<Table.Body> |
|
44
|
<Table.Row> |
|
45
|
<Table.Cell> |
|
46
|
[StoreCurrency](/references/store/models/StoreCurrency) |
|
47
|
</Table.Cell> |
|
48
|
<Table.Cell> |
|
49
|
[Currency](/references/currency/models/Currency) in [Currency Module](../../currency/page.mdx) |
|
50
|
</Table.Cell> |
|
51
|
<Table.Cell> |
|
52
|
Read-only - has many |
|
53
|
</Table.Cell> |
|
54
|
<Table.Cell> |
|
55
|
[Learn more](#currency-module) |
|
56
|
</Table.Cell> |
|
57
|
</Table.Row> |
|
58
|
<Table.Row> |
|
59
|
<Table.Cell> |
|
60
|
[StoreLocale](/references/store/models/StoreLocale) |
|
61
|
</Table.Cell> |
|
62
|
<Table.Cell> |
|
63
|
[Locale](/references/translation/models/Locale) in [Translation Module](../../translation/page.mdx) |
|
64
|
</Table.Cell> |
|
65
|
<Table.Cell> |
|
66
|
Read-only - has many |
|
67
|
</Table.Cell> |
|
68
|
<Table.Cell> |
|
69
|
[Learn more](#translation-module) |
|
70
|
</Table.Cell> |
|
71
|
</Table.Row> |
|
72
|
</Table.Body> |
|
73
|
</Table> |
|
74
|
|
|
75
|
--- |
|
76
|
|
|
77
|
## Currency Module |
|
78
|
|
|
79
|
The Store Module has a `StoreCurrency` 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. |
|
80
|
|
|
81
|
Instead, Medusa defines a read-only link from the Store Module's `StoreCurrency` data model to the [Currency Module](../../currency/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. |
|
82
|
|
|
83
|
### Retrieve with Query |
|
84
|
|
|
85
|
To retrieve the details of a store's currencies with [Query](!docs!/learn/fundamentals/query), pass `supported_currencies.currency.*` in `fields`: |
|
86
|
|
|
87
|
<CodeTabs group="relation-query"> |
|
88
|
<CodeTab label="query.graph" value="method"> |
|
89
|
|
|
90
|
```ts |
|
91
|
const { data: stores } = await query.graph({ |
|
92
|
entity: "store", |
|
93
|
fields: [ |
|
94
|
"supported_currencies.currency.*", |
|
95
|
], |
|
96
|
}) |
|
97
|
|
|
98
|
// stores[0].supported_currencies |
|
99
|
``` |
|
100
|
|
|
101
|
</CodeTab> |
|
102
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
103
|
|
|
104
|
```ts |
|
105
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
106
|
|
|
107
|
// ... |
|
108
|
|
|
109
|
const { data: stores } = useQueryGraphStep({ |
|
110
|
entity: "store", |
|
111
|
fields: [ |
|
112
|
"supported_currencies.currency.*", |
|
113
|
], |
|
114
|
}) |
|
115
|
|
|
116
|
// stores[0].supported_currencies |
|
117
|
``` |
|
118
|
|
|
119
|
</CodeTab> |
|
120
|
</CodeTabs> |
|
121
|
|
|
122
|
|
|
123
|
--- |
|
124
|
|
|
125
|
## Translation Module |
|
126
|
|
|
127
|
<Prerequisites |
|
128
|
items={[ |
|
129
|
{ |
|
130
|
text: "Translation Module Configured", |
|
131
|
link: "/commerce-modules/translation#configure-translation-module", |
|
132
|
} |
|
133
|
]} |
|
134
|
/> |
|
135
|
|
|
136
|
The Store Module has a `StoreLocale` data model that stores the supported locales of a store. However, these locales don't hold all the details of a locale, such as its name. |
|
137
|
|
|
138
|
Instead, Medusa defines a read-only link from the Store Module's `StoreLocale` data model to the [Translation Module](../../translation/page.mdx)'s `Locale` data model. This means you can retrieve the details of a store's supported locales, but you don't manage the links in a pivot table in the database. |
|
139
|
|
|
140
|
### Retrieve with Query |
|
141
|
|
|
142
|
To retrieve the details of a store's locales with [Query](!docs!/learn/fundamentals/query), pass `supported_locales.locale.*` in `fields`: |
|
143
|
|
|
144
|
<CodeTabs group="relation-query"> |
|
145
|
<CodeTab label="query.graph" value="method"> |
|
146
|
|
|
147
|
```ts |
|
148
|
const { data: stores } = await query.graph({ |
|
149
|
entity: "store", |
|
150
|
fields: [ |
|
151
|
"supported_locales.locale.*", |
|
152
|
], |
|
153
|
}) |
|
154
|
|
|
155
|
// stores[0].supported_locales[0].locale |
|
156
|
``` |
|
157
|
|
|
158
|
</CodeTab> |
|
159
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
160
|
|
|
161
|
```ts |
|
162
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
163
|
|
|
164
|
// ... |
|
165
|
|
|
166
|
const { data: stores } = useQueryGraphStep({ |
|
167
|
entity: "store", |
|
168
|
fields: [ |
|
169
|
"supported_locales.locale.*", |
|
170
|
], |
|
171
|
}) |
|
172
|
|
|
173
|
// stores[0].supported_locales[0].locale |
|
174
|
``` |
|
175
|
|
|
176
|
</CodeTab> |
|
177
|
</CodeTabs> |