我正在尝试在loopback.io中执行不在查询中的操作。但是找不到与此相关的任何功能。这是我尝试过的:
Product.find({
where: {
name: {
like: '%' + searchTerm + '%'
},
id: {
neq: [1,2,3]
}
},
limit: 15
}, function(err, searchResults) {...}
实际上生成的查询是:
'SELECT `id`,`name`,`ref` FROM `Product` WHERE `name` LIKE \'%iPh%\' AND `id`!=1, 2, 3 ORDER BY `id` LIMIT 15' }
我知道我们可以检查
field in (n1,n2,...)
使用https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-inq。但是我不能接受“不存在”的情况。
有人遇到过这种情况吗?
您所使用neq
的确实用于您提供的不等于。要使用Not In运算符,必须使用nin
。再次检查文档,其中有一个带有操作员说明的表格
Product.find({
where: {
name: {
like: '%' + searchTerm + '%'
},
id: {
nin: [1,2,3]
}
},
limit: 15
}, function(err, searchResults) {...}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句