* chore(): Mikro orm 6.4.16 * Create small-ghosts-draw.md * update config * update config * fix delete * update config * update workflows * order improvements * test pricing quuery * test pricing quuery * configurable connection options * configurable connection options * configurable connection options * Update packages/modules/pricing/src/models/price.ts Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
40 lines
952 B
TypeScript
40 lines
952 B
TypeScript
import { model, PricingRuleOperator } from "@medusajs/framework/utils"
|
|
import Price from "./price"
|
|
|
|
const PriceRule = model
|
|
.define("PriceRule", {
|
|
id: model.id({ prefix: "prule" }).primaryKey(),
|
|
attribute: model.text(),
|
|
value: model.text(),
|
|
operator: model.enum(PricingRuleOperator).default(PricingRuleOperator.EQ),
|
|
priority: model.number().default(0),
|
|
price: model.belongsTo(() => Price, {
|
|
mappedBy: "price_rules",
|
|
}),
|
|
})
|
|
.indexes([
|
|
{
|
|
on: ["price_id", "attribute", "operator"],
|
|
where: "deleted_at IS NULL",
|
|
unique: true,
|
|
},
|
|
{
|
|
on: ["attribute"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
{
|
|
on: ["attribute", "value"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
{
|
|
on: ["operator", "value"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
{
|
|
on: ["attribute", "value", "price_id"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
])
|
|
|
|
export default PriceRule
|