【发布时间】:2021-07-19 17:54:30
【问题描述】:
em.nativeDelete 返回有多少实体被删除,所以我可以这样做:
const count = await this.em.nativeDelete(User, {id});
if(!count){
throw new EntitiyNotFoundException(`User with id: ${id} is not found`);
}
有没有办法用 remove() 做同样的事情。它返回 EntityManager 我如何检查是否删除了实体:
const user = this.em.getReference(User, id);
await this.em.remove(user);
【问题讨论】:
标签: mikro-orm