feat(user): Init user module (#6293)
* init user module * add migration * update module with latest utils * pr ready * make interface types interfaces
This commit is contained in:
1
packages/user/src/models/index.ts
Normal file
1
packages/user/src/models/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as User } from "./user"
|
||||
25
packages/user/src/models/user.ts
Normal file
25
packages/user/src/models/user.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
OnInit,
|
||||
PrimaryKey,
|
||||
} from "@mikro-orm/core"
|
||||
|
||||
import { generateEntityId } from "@medusajs/utils"
|
||||
|
||||
|
||||
@Entity()
|
||||
export default class User {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id!: string
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "user")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
onInit() {
|
||||
this.id = generateEntityId(this.id, "user")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user