1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { LINKS, Modules } from "@medusajs/framework/utils"
3
4 export const OrderPaymentCollection: ModuleJoinerConfig = {
5 serviceName: LINKS.OrderPaymentCollection,
6 isLink: true,
7 databaseConfig: {
8 tableName: "order_payment_collection",
9 idPrefix: "ordpay",
10 },
11 alias: [
12 {
13 name: ["order_payment_collection", "order_payment_collections"],
14 entity: "LinkOrderPaymentCollection",
15 },
16 ],
17 primaryKeys: ["id", "order_id", "payment_collection_id"],
18 relationships: [
19 {
20 serviceName: Modules.ORDER,
21 entity: "Order",
22 primaryKey: "id",
23 foreignKey: "order_id",
24 alias: "order",
25 args: {
26 methodSuffix: "Orders",
27 },
28 },
29 {
30 serviceName: Modules.PAYMENT,
31 entity: "PaymentCollection",
32 primaryKey: "id",
33 foreignKey: "payment_collection_id",
34 alias: "payment_collection",
35 args: {
36 methodSuffix: "PaymentCollections",
37 },
38 deleteCascade: true,
39 hasMany: true,
40 },
41 ],
42 extends: [
43 {
44 serviceName: Modules.ORDER,
45 entity: "Order",
46 fieldAlias: {
47 payment_collections: {
48 path: "payment_collections_link.payment_collection",
49 isList: true,
50 },
51 },
52 relationship: {
53 serviceName: LINKS.OrderPaymentCollection,
54 primaryKey: "order_id",
55 foreignKey: "id",
56 alias: "payment_collections_link",
57 },
58 },
59 {
60 serviceName: Modules.PAYMENT,
61 entity: "PaymentCollection",
62 fieldAlias: {
63 order: "order_link.order",
64 },
65 relationship: {
66 serviceName: LINKS.OrderPaymentCollection,
67 primaryKey: "payment_collection_id",
68 foreignKey: "id",
69 alias: "order_link",
70 },
71 },
72 ],
73 }