Strongloop同时用(or)和(and)查询数据
Strongloop querying data with (or) and (and) at the same time
我需要这样做。
select *
from person
where (firstname like '%a' or lastname like "%a") and id NOT IN (1 , 2)
node.js:
BegroupdUser.find({
limit: limit,
skip: skip,
where: {
id: { nin: adminIds },
or: [{
firstName: {like: '%' + _query + '%'}
}, {
lastName: {like: '%' + _query + '%'}
}]
}
}, function (errors, users) {
});
阅读本文:https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-and/or
您似乎需要将 or
嵌套在 and
中,并使用正则表达式代替 like
运算符。
试试这个
{
"where": {
"and": [
{
"id": {
"nin": adminIds
}
},
{
"or": [{
firstName: {like: '%' + _query + '%'}},
{
lastName: {like: '%' + _query + '%'}}
]
}
]
}
}
我需要这样做。
select *
from person
where (firstname like '%a' or lastname like "%a") and id NOT IN (1 , 2)
node.js:
BegroupdUser.find({
limit: limit,
skip: skip,
where: {
id: { nin: adminIds },
or: [{
firstName: {like: '%' + _query + '%'}
}, {
lastName: {like: '%' + _query + '%'}
}]
}
}, function (errors, users) {
});
阅读本文:https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-and/or
您似乎需要将 or
嵌套在 and
中,并使用正则表达式代替 like
运算符。
试试这个
{
"where": {
"and": [
{
"id": {
"nin": adminIds
}
},
{
"or": [{
firstName: {like: '%' + _query + '%'}},
{
lastName: {like: '%' + _query + '%'}}
]
}
]
}
}