diff --git a/www/apps/book/app/advanced-development/data-models/relationships/page.mdx b/www/apps/book/app/advanced-development/data-models/relationships/page.mdx
index 0db3719ce9..ddf61e4d8c 100644
--- a/www/apps/book/app/advanced-development/data-models/relationships/page.mdx
+++ b/www/apps/book/app/advanced-development/data-models/relationships/page.mdx
@@ -12,6 +12,18 @@ Data model relationships are in active development and may change.
+
+
+- You want to create a relation between data models in the same module.
+
+
+
+
+
+- You want to create a relationship between data models in different modules. Use module links instead.
+
+
+
## What is a Relationship Property?
A relationship property is defined using relation methods, such as `hasOne` or `belongsTo`. It represents a relationship between two data models in a module.
diff --git a/www/apps/book/app/advanced-development/modules/module-links/page.mdx b/www/apps/book/app/advanced-development/modules/module-links/page.mdx
index deebd0fb84..ef0f5dead8 100644
--- a/www/apps/book/app/advanced-development/modules/module-links/page.mdx
+++ b/www/apps/book/app/advanced-development/modules/module-links/page.mdx
@@ -18,6 +18,18 @@ A module link forms an association between two data models of different modules,
You can then retrieve data across the linked modules, and manage their linked records.
+
+
+- You want to create a relation between data models from different modules.
+
+
+
+
+
+- You want to create a relationship between data models in the same module. Use data model relationships instead.
+
+
+
---
## Prerequisite: isQueryable Configuration
@@ -27,10 +39,13 @@ Before you define a module link, you must enable the `isQueryable` configuration
For example:
```js
+import { HELLO_MODULE } from "./src/modules/hello"
+// ...
+
module.exports = defineConfig({
// ...
modules: {
- helloModuleService: {
+ [HELLO_MODULE]: {
resolve: "./modules/hello",
definition: {
isQueryable: true,
diff --git a/www/apps/book/app/advanced-development/modules/options/page.mdx b/www/apps/book/app/advanced-development/modules/options/page.mdx
index cbe7478862..09f3fe6580 100644
--- a/www/apps/book/app/advanced-development/modules/options/page.mdx
+++ b/www/apps/book/app/advanced-development/modules/options/page.mdx
@@ -23,10 +23,13 @@ To pass options to a module, add an `options` property to the module’s configu
For example:
```js title="medusa-config.js"
+import { HELLO_MODULE } from "./src/modules/hello"
+// ...
+
module.exports = defineConfig({
// ...
modules: {
- helloModuleService: {
+ [HELLO_MODULE]: {
resolve: "./modules/hello",
options: {
capitalize: true,
diff --git a/www/apps/book/app/advanced-development/modules/service-factory/page.mdx b/www/apps/book/app/advanced-development/modules/service-factory/page.mdx
index bd0e2918c4..ea64e8c1a4 100644
--- a/www/apps/book/app/advanced-development/modules/service-factory/page.mdx
+++ b/www/apps/book/app/advanced-development/modules/service-factory/page.mdx
@@ -1,4 +1,4 @@
-import { Table } from "docs-ui"
+import { Tabs, TabsContent, TabsContentWrapper, TabsList, TabsTrigger } from "docs-ui"
export const metadata = {
title: `${pageNumber} Service Factory`,
@@ -60,118 +60,216 @@ The method's names are the operation's name, suffixed by the data model's name.
For example, the following methods are generated for the code snippet above:
-
-
-
- Method
- Description
-
-
-
-
-
-
- `listMyCustoms`
+
+
+ listMyCustoms
+ listAndCountMyCustoms
+ retrieveMyCustom
+ createMyCustoms
+ updateMyCustoms
+ deleteMyCustoms
+ softDeleteMyCustoms
+ restoreMyCustoms
+
+
+
-
-
-
- Retrieves an array of records based on filters and pagination configurations.
+ ### listMyCustoms
-
-
-
-
-
- `listAndCountMyCustoms`
+ This method retrieves an array of records based on filters and pagination configurations.
-
-
-
- Retrieves a tuple of an array of records and the total count of available records based on the filters and pagination configurations provided.
+ For example:
-
-
-
-
-
- `retrieveMyCustom`
+ ```ts
+ const myCustoms = await helloModuleService
+ .listMyCustoms()
-
-
-
- Retrieves a record by its ID.
+ // with filters
+ const myCustoms = await helloModuleService
+ .listMyCustoms({
+ id: ["123"]
+ })
+ ```
-
-
-
-
-
- `createMyCustoms`
+
+
-
-
-
- Create and retrieve records of the data model.
+ ### listAndCountMyCustoms
-
-
-
-
-
- `updateMyCustoms`
+ This method retrieves a tuple of an array of records and the total count of available records based on the filters and pagination configurations provided.
-
-
-
- Update and retrieve records of the data model.
+ For example:
-
-
-
-
-
- `deleteMyCustoms`
+ ```ts
+ const [
+ myCustoms,
+ count
+ ] = await helloModuleService.listAndCountMyCustoms()
-
-
-
- Deletes records by an ID or filter.
+ // with filters
+ const [
+ myCustoms,
+ count
+ ] = await helloModuleService.listAndCountMyCustoms({
+ id: ["123"]
+ })
+ ```
-
-
-
-
-
- `softDeleteMyCustoms`
+
+
-
-
-
- Soft-deletes records using an array of IDs or an object of filters.
+ ### retrieveMyCustom
-
-
-
-
-
- `restoreMyCustoms`
+ This method retrieves a record by its ID.
-
-
-
- Restores soft-deleted records using an array of IDs or an object of filters.
+ For example:
-
-
-
-
+ ```ts
+ const myCustom = await helloModuleService
+ .retrieveMyCustom("123")
+ ```
-
+
+
-Except for the `retrieve` method, the suffixed data model's name is plural.
+ ### createMyCustoms
-
+ This method creates and retrieves records of the data model.
+
+ For example:
+
+ ```ts
+ const myCustom = await helloModuleService
+ .createMyCustoms({
+ name: "test"
+ })
+
+ // create multiple
+ const myCustoms = await helloModuleService
+ .createMyCustoms([
+ {
+ name: "test"
+ },
+ {
+ name: "test 2"
+ },
+ ])
+ ```
+
+
+
+
+ ### updateMyCustoms
+
+ This method updates and retrieves records of the data model.
+
+ For example:
+
+ ```ts
+ const myCustom = await helloModuleService
+ .updateMyCustoms({
+ id: "123",
+ name: "test"
+ })
+
+ // update multiple
+ const myCustoms = await helloModuleService
+ .updateMyCustoms([
+ {
+ id: "123",
+ name: "test"
+ },
+ {
+ id: "321",
+ name: "test 2"
+ },
+ ])
+
+ // use filters
+ const myCustoms = await helloModuleService
+ .updateMyCustoms([
+ {
+ selector: {
+ id: ["123", "321"]
+ },
+ data: {
+ name: "test"
+ }
+ },
+ ])
+ ```
+
+
+
+
+ ### deleteMyCustoms
+
+ This method deletes records by an ID or filter.
+
+ For example:
+
+ ```ts
+ await helloModuleService.deleteMyCustoms("123")
+
+ // delete multiple
+ await helloModuleService.deleteMyCustoms([
+ "123", "321"
+ ])
+
+ // use filters
+ await helloModuleService.deleteMyCustoms({
+ selector: {
+ id: ["123", "321"]
+ }
+ })
+ ```
+
+
+
+
+ ### softDeleteMyCustoms
+
+ This method soft-deletes records using an array of IDs or an object of filters.
+
+ For example:
+
+ ```ts
+ await helloModuleService.softDeleteMyCustoms("123")
+
+ // soft-delete multiple
+ await helloModuleService.softDeleteMyCustoms([
+ "123", "321"
+ ])
+
+ // use filters
+ await helloModuleService.softDeleteMyCustoms({
+ id: ["123", "321"]
+ })
+ ```
+
+
+
+
+ ### restoreMyCustoms
+
+ This method restores soft-deleted records using an array of IDs or an object of filters.
+
+ For example:
+
+ ```ts
+ await helloModuleService.restoreMyCustoms([
+ "123", "321"
+ ])
+
+ // use filters
+ await helloModuleService.restoreMyCustoms({
+ id: ["123", "321"]
+ })
+ ```
+
+
+
+
### Using a Constructor
diff --git a/www/apps/book/app/basics/data-models/page.mdx b/www/apps/book/app/basics/data-models/page.mdx
index ec2da01a25..d09cbac1c5 100644
--- a/www/apps/book/app/basics/data-models/page.mdx
+++ b/www/apps/book/app/basics/data-models/page.mdx
@@ -39,7 +39,7 @@ export default MyCustom
You define a data model using the `model`'s `define` method. It accepts two parameters:
-1. The first one is the name of the data model's table in the database.
+1. The first one is the name of the data model's table in the database. It should be in snake-case form.
2. The second is an object, which is the data model's schema. The schema's properties are defined using the `model`'s methods.
The example above defines the data model `MyCustom` with the properties `id` and `name`.
diff --git a/www/apps/book/app/basics/modules-and-services/page.mdx b/www/apps/book/app/basics/modules-and-services/page.mdx
index 15e01c33ad..44f3a3ed0f 100644
--- a/www/apps/book/app/basics/modules-and-services/page.mdx
+++ b/www/apps/book/app/basics/modules-and-services/page.mdx
@@ -52,7 +52,9 @@ For example, create the file `src/modules/hello/index.ts` with the following con
import HelloModuleService from "./service"
import { Module } from "@medusajs/utils"
-export default Module("helloModuleService", {
+export const HELLO_MODULE = "helloModuleService"
+
+export default Module(HELLO_MODULE, {
service: HelloModuleService,
})
```
@@ -68,18 +70,21 @@ The last step is to add the module in Medusa’s configurations.
In `medusa-config.js`, add a `modules` property and pass to it your custom module:
-```js title="medusa-config.js" highlights={[["4", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
+```js title="medusa-config.js" highlights={[["7", "HELLO_MODULE", "The key of the main service to be registered in the Medusa container."]]}
+import { HELLO_MODULE } from "./src/modules/hello"
+// ...
+
module.exports = defineConfig({
// ...
modules: {
- helloModuleService: {
+ [HELLO_MODULE]: {
resolve: "./modules/hello",
},
},
})
```
-Its key (`helloModuleService`) is the name of the module’s main service. It will be registered in the Medusa container with that name. It should also be the same name passed as the first parameter to the `Module` function in the module's definition.
+Its key (`helloModuleService` or `HELLO_MODULE`) is the name of the module’s main service. It will be registered in the Medusa container with that name. It should also be the same name passed as the first parameter to the `Module` function in the module's definition.
Its value is an object having the `resolve` property, whose value is either a path to module's directory relative to `src`(it shouldn't include `src` in the path), or an `npm` package’s name.
@@ -94,13 +99,14 @@ For example, create the API route `src/api/store/custom/route.ts` with the follo
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import HelloModuleService from "../../../modules/hello/service"
+import { HELLO_MODULE } from "../../../modules/hello"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise {
const helloModuleService: HelloModuleService = req.scope.resolve(
- "helloModuleService"
+ HELLO_MODULE
)
res.json({
diff --git a/www/apps/book/app/cheatsheet/page.mdx b/www/apps/book/app/cheatsheet/page.mdx
index 9da723135a..d269c9d8a5 100644
--- a/www/apps/book/app/cheatsheet/page.mdx
+++ b/www/apps/book/app/cheatsheet/page.mdx
@@ -45,6 +45,19 @@ This chapter provides a cheat sheet for Medusa's resources on when to use or not
+
+ Module Links
+
+
+ - You want to create a relation between data models from different modules.
+
+
+
+
+ - You want to create a relationship between data models in the same module. Use data model relationships instead.
+
+
+
Data Models
@@ -58,6 +71,19 @@ This chapter provides a cheat sheet for Medusa's resources on when to use or not
+
+ Data Model Relationships
+
+
+ - You want to create a relation between data models in the same module.
+
+
+
+
+ - You want to create a relationship between data models in different modules. Use module links instead.
+
+
+
Loaders
diff --git a/www/apps/book/app/favicon.ico b/www/apps/book/app/favicon.ico
index 718d6fea48..bebbf17e40 100644
Binary files a/www/apps/book/app/favicon.ico and b/www/apps/book/app/favicon.ico differ
diff --git a/www/apps/book/app/icon.ico b/www/apps/book/app/icon.ico
new file mode 100644
index 0000000000..bebbf17e40
Binary files /dev/null and b/www/apps/book/app/icon.ico differ
diff --git a/www/apps/book/app/opengraph-image.jpg b/www/apps/book/app/opengraph-image.jpg
new file mode 100644
index 0000000000..8e6f6515dd
Binary files /dev/null and b/www/apps/book/app/opengraph-image.jpg differ
diff --git a/www/apps/book/app/twitter-image.jpg b/www/apps/book/app/twitter-image.jpg
new file mode 100644
index 0000000000..8e6f6515dd
Binary files /dev/null and b/www/apps/book/app/twitter-image.jpg differ
diff --git a/www/apps/resources/app/favicon.ico b/www/apps/resources/app/favicon.ico
index 718d6fea48..bebbf17e40 100644
Binary files a/www/apps/resources/app/favicon.ico and b/www/apps/resources/app/favicon.ico differ
diff --git a/www/apps/resources/app/icon.ico b/www/apps/resources/app/icon.ico
new file mode 100644
index 0000000000..bebbf17e40
Binary files /dev/null and b/www/apps/resources/app/icon.ico differ
diff --git a/www/apps/resources/app/opengraph-image.jpg b/www/apps/resources/app/opengraph-image.jpg
new file mode 100644
index 0000000000..89c90792ca
Binary files /dev/null and b/www/apps/resources/app/opengraph-image.jpg differ
diff --git a/www/apps/resources/app/twitter-image.jpg b/www/apps/resources/app/twitter-image.jpg
new file mode 100644
index 0000000000..89c90792ca
Binary files /dev/null and b/www/apps/resources/app/twitter-image.jpg differ