如何解决在 Mikro-ORM 中持久化新实体时,解决公式的最佳方法是什么?
插入新记录后,我意识到对象中的所有公式属性都为空。
这是一个实体:
@Entity()
export class Book extends BaseEntity {
@property()
title: string;
@property()
width: number;
@property()
height: number;
@Formula('width * height')
area?: number;
constructor(title: string,width: number,height: number) {
this.title = title;
this.width = width;
this.height = height;
}
}
我现在正在做的是在用 findOne
刷新后立即按 id 生成 refresh: true
。
const book = new Book('test',15,20);
em.persist(book);
await em.flush();
await em.findOne({ id: book.id },{ refresh: true });
我在文档中找不到任何对此的引用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。