环回4允许使用一个真正有用的自动/默认过滤器。我的问题是,我想使用它在一个自定义的方式,我不能。
通常:
return this.customerRepository.findById(idCustomer, filter);
我的情况:
我不想攻击"在这个模型中,我想攻击另一个领域。我试过很多方法,但作为简历的一个例子:
return this.customerRepository.findOne({where: { idUser: currentUserProfile.id }}, filter));
如果我这样做,过滤器停止工作。任何想法如何混合一个字段的模型不同于id和环回4的过滤器?
Thanks in advance
问好@Jota你说过滤器停止工作是什么意思?你对这个方法的想法是正确的。要按特定字段进行搜索,只需将其放在where子句中:
this.customerRepository.findOne({ where: { <field_name>: <value_to_search> } })
。
const filter = {
where: {
email: 'hello@world.com'
}
};
const result = await this.customerRepository.findOne(filter);