feat: Add basic endpoints and workflows for Store module (#6515)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user