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);