We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用TypeORM来操作Mysql数据库,使用装饰器来定义Entity
/** * 用户 */ @Entity('sys_user') export class UserEntity extends BaseEntity { @ManyToOne(() => DepartmentEntity, (department) => department) @JoinColumn() department: DepartmentEntity; @ManyToMany(() => RoleEntity) @JoinTable() roles: RoleEntity[]; @Column({ comment: '邮箱' }) email: string; @Column({ comment: '密码' }) password: string; @Column({ comment: '昵称' }) nickname: string; @Column({ comment: '状态 0-禁用 1-启用', type: 'enum', enum: UserStatus, default: UserStatus.Enabled, }) status: UserStatus; }
将Entit作为类型使用
export type ResGetData= UserEntity;
启动报错,信息如下:
⨯ Cannot find reference target '../entities/sys/user.entity/UserEntity' at ResGetData at PtlGetData ⨯ ServiceProto 生成失败,请检查 TypeScript 代码是否编译报错: src/shared/protocols/serviceProto.ts
看起来装饰器的Entity在当前环境无法正确编译
The text was updated successfully, but these errors were encountered:
已解决部分问题
{ "compilerOptions": { "experimentalDecorators": true, "strictPropertyInitialization": false, "emitDecoratorMetadata": true } }
可以正常运行,但是如何去复用entity定义的类型呢?看起来就是复杂的entity定义无法顺利编译出proto文件
Sorry, something went wrong.
是的,目前还没有支持 class 类型,支持 TypeORM 在 Todo List 中...
当然,如果使用 MongoDB 的话,可以无需 ORM...
No branches or pull requests
背景
使用TypeORM来操作Mysql数据库,使用装饰器来定义Entity
将Entit作为类型使用
启动报错,信息如下:
⨯ Cannot find reference target '../entities/sys/user.entity/UserEntity'
at ResGetData
at PtlGetData
⨯ ServiceProto 生成失败,请检查 TypeScript 代码是否编译报错: src/shared/protocols/serviceProto.ts
看起来装饰器的Entity在当前环境无法正确编译
The text was updated successfully, but these errors were encountered: