Files
medusa-store/packages/modules/providers/locking-postgres/src/models/locking.ts
Carlos R. L. Rodrigues e9a06f4b4d fea(providers): locking postgres (#9545)
Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-17 13:11:39 +00:00

33 lines
625 B
TypeScript

import { generateEntityId } from "@medusajs/framework/utils"
import {
BeforeCreate,
Entity,
OnInit,
PrimaryKey,
Property,
} from "@mikro-orm/core"
@Entity({ tableName: "locking" })
class Locking {
@PrimaryKey({ columnType: "text" })
id!: string
@Property({ columnType: "text", nullable: true })
owner_id: string | null = null
@Property({ columnType: "timestamptz", nullable: true })
expiration: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "lk")
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "lk")
}
}
export default Locking