feat: Add basic endpoints and workflows for Store module (#6515)

This commit is contained in:
Stevche Radevski
2024-02-28 11:08:11 +01:00
committed by GitHub
parent 70aeb602c9
commit d60f3adc03
26 changed files with 596 additions and 13 deletions
+33 -2
View File
@@ -1,4 +1,10 @@
import { generateEntityId } from "@medusajs/utils"
import {
DALUtils,
createPsqlIndexStatementHelper,
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
@@ -6,14 +12,27 @@ import {
OnInit,
PrimaryKey,
Property,
Filter,
OptionalProps,
} from "@mikro-orm/core"
type StoreOptionalProps = DAL.SoftDeletableEntityDateColumns
const StoreDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "store",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class Store {
[OptionalProps]?: StoreOptionalProps
@PrimaryKey({ columnType: "text" })
id: string
@Property({ columnType: "text" })
@Property({ columnType: "text", default: "Medusa Store" })
name: string
@Property({ columnType: "text", nullable: true })
@@ -35,6 +54,18 @@ export default class Store {
})
created_at: Date
@Property({
onCreate: () => new Date(),
onUpdate: () => new Date(),
columnType: "timestamptz",
defaultRaw: "now()",
})
updated_at: Date
@StoreDeletedAtIndex.MikroORMIndex()
@Property({ columnType: "timestamptz", nullable: true })
deleted_at: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "store")