dro*_*bot 3 strongloop loopbackjs
我正在尝试在loopback.io中进行查询.但找不到与此相关的任何功能.这是我尝试过的:
Product.find({
where: {
name: {
like: '%' + searchTerm + '%'
},
id: {
neq: [1,2,3]
}
},
limit: 15
}, function(err, searchResults) {...}
Run Code Online (Sandbox Code Playgroud)
事实上,生成的查询是:
'SELECT `id`,`name`,`ref` FROM `Product` WHERE `name` LIKE \'%iPh%\' AND `id`!=1, 2, 3 ORDER BY `id` LIMIT 15' }
Run Code Online (Sandbox Code Playgroud)
我知道我们可以检查一下
field in (n1,n2,...)
Run Code Online (Sandbox Code Playgroud)
使用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) {...}
Run Code Online (Sandbox Code Playgroud)