我想在我的存储库中找到名字像“john”的结果OR姓氏就像“doe”
但 findOptions where 子句将其视为 AND。
我尝试过的:
let results = await userRepo.find({
where : {
firstname : Like('%John%'),
lastname : Like('%Doe%'),
}
});
我对此的期望:
let results = await userRepo.find({
where : {
firstname : Like('%John%'),
lastname : Or(Like('%Doe%')),
}
});
有关如何使用的任何帮助OR在哪个对象内?
可以使用简单的 typeorm .find() 选项来使用 OR 子句,如 TypeORM 中所述docs https://github.com/typeorm/typeorm/blob/master/docs/find-options.md.
要使用 OR 运算符进行查询,您需要使用条件数组而不是对象。
let results = await userRepo.find({
where: [
{ firstname: Like('%John%') },
{ lastname: Like('%Doe%') }
]
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)