41 lines
715 B
TypeScript
41 lines
715 B
TypeScript
import {
|
|
BeforeCreate,
|
|
Entity,
|
|
OnInit,
|
|
PrimaryKey,
|
|
Property,
|
|
} from "@mikro-orm/core"
|
|
|
|
import { generateEntityId } from "@medusajs/utils"
|
|
|
|
@Entity({ tableName: "payment" })
|
|
export default class Payment {
|
|
@PrimaryKey({ columnType: "text" })
|
|
id: 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
|
|
|
|
@BeforeCreate()
|
|
onCreate() {
|
|
this.id = generateEntityId(this.id, "pay")
|
|
}
|
|
|
|
@OnInit()
|
|
onInit() {
|
|
this.id = generateEntityId(this.id, "pay")
|
|
}
|
|
}
|