Files
medusa-store/packages/modules/link-modules/src/definitions/order-payment-collection.ts
T
Harminder Virk d3e725a907 feat: add hasMany flag to enforce in app link uniqueness (#12039)
* feat: add createMultiple flag to enforce inApp link uniqueness

* changes

* mocks

* default

* many to many

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-04-02 10:46:51 +02:00

74 lines
1.8 KiB
TypeScript

import { ModuleJoinerConfig } from "@medusajs/framework/types"
import { LINKS, Modules } from "@medusajs/framework/utils"
export const OrderPaymentCollection: ModuleJoinerConfig = {
serviceName: LINKS.OrderPaymentCollection,
isLink: true,
databaseConfig: {
tableName: "order_payment_collection",
idPrefix: "ordpay",
},
alias: [
{
name: ["order_payment_collection", "order_payment_collections"],
entity: "LinkOrderPaymentCollection",
},
],
primaryKeys: ["id", "order_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
args: {
methodSuffix: "Orders",
},
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
args: {
methodSuffix: "PaymentCollections",
},
deleteCascade: true,
hasMany: true,
},
],
extends: [
{
serviceName: Modules.ORDER,
entity: "Order",
fieldAlias: {
payment_collections: {
path: "payment_collections_link.payment_collection",
isList: true,
},
},
relationship: {
serviceName: LINKS.OrderPaymentCollection,
primaryKey: "order_id",
foreignKey: "id",
alias: "payment_collections_link",
},
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
fieldAlias: {
order: "order_link.order",
},
relationship: {
serviceName: LINKS.OrderPaymentCollection,
primaryKey: "payment_collection_id",
foreignKey: "id",
alias: "order_link",
},
},
],
}