【发布时间】:2021-02-04 05:04:43
【问题描述】:
我有以下代码,如果满足条件,我希望它返回一个空对象。我无法将其作为查找条件,因为我希望它自动应用于我拥有的每个实体。
此对象已停用,我希望在执行加载后的函数时返回一个空对象,而不是返回该对象
await this.Repository.find({where: {id: 4}}) // This Object Entity Is Disabled
import { EventSubscriber, EntitySubscriberInterface } from 'typeorm';
@EventSubscriber()
export class BaseSubscriber implements EntitySubscriberInterface {
async afterLoad(entity) {
if (entity.disabled){
return {} //?
}
}
}
【问题讨论】:
标签: node.js typeorm node.js-typeorm