docs: added plugins documentation (#10989)

(Should be merged after the next release)

Closes DX-1294
This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-01-27 09:32:53 +00:00
1 parent 0c5f21e893
commit c26ef84cae
26 files changed
+2901 -52

No files matched your search

@@ -198,7 +198,7 @@ For example, assuming you have the [Order, Product, and OrderProduct models from
class HelloModuleService extends MedusaService({
Order,
Product,
OrderProduct
OrderProduct,
}) {}
```
@@ -212,16 +212,16 @@ const orderProduct = await helloModuleService.createOrderProducts({
order_id: "123",
product_id: "123",
metadata: {
test: true
}
test: true,
},
})
// update order-product association
const orderProduct = await helloModuleService.updateOrderProducts({
id: "123",
metadata: {
test: false
}
test: false,
},
})
// delete order-product association
@@ -217,29 +217,29 @@ export const manyToManyColumnHighlights = [
]
```ts highlights={manyToManyColumnHighlights}
import { model } from "@medusajs/framework/utils";
import { model } from "@medusajs/framework/utils"
export const Order = model.define("order_test", {
id: model.id().primaryKey(),
products: model.manyToMany(() => Product, {
pivotEntity: () => OrderProduct
})
pivotEntity: () => OrderProduct,
}),
})
export const Product = model.define("product_test", {
id: model.id().primaryKey(),
orders: model.manyToMany(() => Order)
orders: model.manyToMany(() => Order),
})
export const OrderProduct = model.define("orders_products", {
id: model.id().primaryKey(),
order: model.belongsTo(() => Order, {
mappedBy: "products"
mappedBy: "products",
}),
product: model.belongsTo(() => Product, {
mappedBy: "orders"
mappedBy: "orders",
}),
metadata: model.json().nullable()
metadata: model.json().nullable(),
})
```