Files
medusa-store/packages/pricing/src/models/price-set.ts
Riqwan Thamir 834da5c41a feat(pricing, types): PriceSets as entry point to pricing module (#4978)
What:
- Adds PriceSet, PriceSetMoneyAmount, updates schema
- Adds service/repo for PriceSet
- Shifts entry point to use PriceSet
- Updates link/joiner config

RESOLVES CORE-1495
2023-09-11 17:24:31 +00:00

29 lines
586 B
TypeScript

import { generateEntityId } from "@medusajs/utils"
import {
BeforeCreate,
Collection,
Entity,
ManyToMany,
PrimaryKey,
} from "@mikro-orm/core"
import MoneyAmount from "./money-amount"
import PriceSetMoneyAmount from "./price-set-money-amount"
@Entity()
export default class PriceSet {
@PrimaryKey({ columnType: "text" })
id!: string
@ManyToMany({
entity: () => MoneyAmount,
pivotEntity: () => PriceSetMoneyAmount,
})
money_amounts = new Collection<MoneyAmount>(this)
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "pset")
}
}