Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The keys (names of linked modules) must be in the same [direction](../directions

## Cascade Delete Linked Records

If a record is deleted, use the `delete` method of Link to delete all linked records.
If you delete a record using a workflow or its module's service, use the `delete` method of Link to delete all linked records whose links are defined with [cascade deletion](../page.mdx#set-delete-cascades-on-link).

For example:

Expand All @@ -184,7 +184,7 @@ import { Modules } from "@medusajs/framework/utils"

// ...

await productModuleService.deleteVariants([variant.id])
await productModuleService.deleteProducts(["prod_123"])

await link.delete({
[Modules.PRODUCT]: {
Expand Down
4 changes: 2 additions & 2 deletions www/apps/book/app/learn/fundamentals/module-links/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default defineLink(

## Set Delete Cascades on Link

To enable delete cascade on a link so that when a record is deleted, its linked records are also deleted, pass the `deleteCascade` property in the object passed to `defineLink`.
To enable delete cascade on a link so that when a record is deleted with [link.delete](./link/page.mdx#cascade-delete-linked-records), its linked records are also deleted, pass the `deleteCascade` property in the object passed to `defineLink`.

For example:

Expand All @@ -174,7 +174,7 @@ export default defineLink(
)
```

In this example, when a product is deleted, its linked `post` record is also deleted.
In this example, when a product is deleted with [link.delete](./link/page.mdx#cascade-delete-linked-records), all linked blog posts are also deleted.

---

Expand Down
4 changes: 2 additions & 2 deletions www/apps/book/generated/edit-dates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const generatedEditDates = {
"app/learn/debugging-and-testing/testing-tools/modules-tests/page.mdx": "2025-07-23T15:32:18.008Z",
"app/learn/fundamentals/module-links/custom-columns/page.mdx": "2025-09-29T16:09:36.116Z",
"app/learn/fundamentals/module-links/directions/page.mdx": "2025-03-17T12:52:06.161Z",
"app/learn/fundamentals/module-links/page.mdx": "2025-04-17T08:50:17.036Z",
"app/learn/fundamentals/module-links/page.mdx": "2025-11-28T13:45:06.742Z",
"app/learn/fundamentals/module-links/query/page.mdx": "2025-10-27T09:30:26.957Z",
"app/learn/fundamentals/modules/db-operations/page.mdx": "2025-10-28T16:02:06.265Z",
"app/learn/fundamentals/modules/multiple-services/page.mdx": "2025-03-18T15:11:44.632Z",
Expand Down Expand Up @@ -98,7 +98,7 @@ export const generatedEditDates = {
"app/learn/fundamentals/workflows/multiple-step-usage/page.mdx": "2025-08-01T14:59:59.501Z",
"app/learn/installation/page.mdx": "2025-11-26T12:14:47.372Z",
"app/learn/fundamentals/data-models/check-constraints/page.mdx": "2025-07-25T13:50:21.065Z",
"app/learn/fundamentals/module-links/link/page.mdx": "2025-04-07T08:03:14.513Z",
"app/learn/fundamentals/module-links/link/page.mdx": "2025-11-28T13:42:03.037Z",
"app/learn/fundamentals/workflows/store-executions/page.mdx": "2025-04-17T08:29:10.166Z",
"app/learn/fundamentals/plugins/create/page.mdx": "2025-04-17T08:29:09.910Z",
"app/learn/fundamentals/plugins/page.mdx": "2025-01-22T10:14:10.433Z",
Expand Down
8 changes: 4 additions & 4 deletions www/apps/book/public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15622,7 +15622,7 @@ The keys (names of linked modules) must be in the same [direction](https://docs.

## Cascade Delete Linked Records

If a record is deleted, use the `delete` method of Link to delete all linked records.
If you delete a record using a workflow or its module's service, use the `delete` method of Link to delete all linked records whose links are defined with [cascade deletion](https://docs.medusajs.com/learn/fundamentals/module-links#set-delete-cascades-on-link/index.html.md).

For example:

Expand All @@ -15631,7 +15631,7 @@ import { Modules } from "@medusajs/framework/utils"

// ...

await productModuleService.deleteVariants([variant.id])
await productModuleService.deleteProducts(["prod_123"])

await link.delete({
[Modules.PRODUCT]: {
Expand Down Expand Up @@ -15802,7 +15802,7 @@ export default defineLink(

## Set Delete Cascades on Link

To enable delete cascade on a link so that when a record is deleted, its linked records are also deleted, pass the `deleteCascade` property in the object passed to `defineLink`.
To enable delete cascade on a link so that when a record is deleted with [link.delete](https://docs.medusajs.com/learn/fundamentals/module-links/link#cascade-delete-linked-records/index.html.md), its linked records are also deleted, pass the `deleteCascade` property in the object passed to `defineLink`.

For example:

Expand All @@ -15820,7 +15820,7 @@ export default defineLink(
)
```

In this example, when a product is deleted, its linked `post` record is also deleted.
In this example, when a product is deleted with [link.delete](https://docs.medusajs.com/learn/fundamentals/module-links/link#cascade-delete-linked-records/index.html.md), all linked blog posts are also deleted.

***

Expand Down
Loading