**What** Scafold the fulfillment module basic structure **Bonus** Simplified module scaffolding with new factories and less directories to manage - mikro orm connection loader factory - initialize factory FIXES CORE-1709 FIXES CORE-1710
57 lines
1.1 KiB
TypeScript
57 lines
1.1 KiB
TypeScript
import { DALUtils, generateEntityId } from "@medusajs/utils"
|
|
|
|
import {
|
|
BeforeCreate,
|
|
Entity,
|
|
Filter,
|
|
Index,
|
|
OnInit,
|
|
OptionalProps,
|
|
PrimaryKey,
|
|
Property,
|
|
} from "@mikro-orm/core"
|
|
import { DAL } from "@medusajs/types"
|
|
|
|
type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
|
|
|
|
@Entity()
|
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
export default class FulfillmentSet {
|
|
[OptionalProps]?: FulfillmentSetOptionalProps
|
|
|
|
@PrimaryKey({ columnType: "text" })
|
|
id: string
|
|
|
|
@Property({ columnType: "text" })
|
|
name: string
|
|
|
|
@Property({
|
|
onCreate: () => new Date(),
|
|
columnType: "timestamptz",
|
|
defaultRaw: "now()",
|
|
})
|
|
created_at: Date
|
|
|
|
@Property({
|
|
onCreate: () => new Date(),
|
|
onUpdate: () => new Date(),
|
|
columnType: "timestamptz",
|
|
defaultRaw: "now()",
|
|
})
|
|
updated_at: Date
|
|
|
|
@Index({ name: "IDX_fulfillment_set_deleted_at" })
|
|
@Property({ columnType: "timestamptz", nullable: true })
|
|
deleted_at: Date | null = null
|
|
|
|
@BeforeCreate()
|
|
onCreate() {
|
|
this.id = generateEntityId(this.id, "fuset")
|
|
}
|
|
|
|
@OnInit()
|
|
onInit() {
|
|
this.id = generateEntityId(this.id, "fuset")
|
|
}
|
|
}
|