- 添加 MikroORM CLI 和实体生成器依赖包 - 配置 ESLint 规则以适配 MikroORM 生成的实体文件 - 添加 mikro-orm 和 generate-entities 命令脚本 - 更新 pnpm 锁定文件包含新依赖项 - 移除手动创建的 meeting-user 实体文件,改用 ORM 自动生成
18 lines
570 B
TypeScript
18 lines
570 B
TypeScript
import { defineEntity, p } from '@mikro-orm/core';
|
|
|
|
export class MeetingUser {
|
|
id!: bigint;
|
|
longUserId!: bigint;
|
|
createdAt?: Date;
|
|
}
|
|
|
|
export const MeetingUserSchema = defineEntity({
|
|
class: MeetingUser,
|
|
uniques: [{ name: 'idx_hostUserId', properties: ['longUserId'] }],
|
|
properties: {
|
|
id: p.bigint().primary().unsigned(false).comment('短id'),
|
|
longUserId: p.bigint().name('long_user_Id').comment('用户的uid').unique('hostUserId'),
|
|
createdAt: p.datetime().length(3).nullable().comment('创建时间').defaultRaw(`current_timestamp(3)`),
|
|
},
|
|
});
|