Strongloop:用[and]和[or]条件一起过滤数据 [英] Strongloop: filter data with [and] and [or] conditions together
本文介绍了Strongloop:用[and]和[or]条件一起过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用and"和or"条件过滤数据.我想得到这个 mySql 查询:
I'm trying to filter data using "and" and "or" conditions. I would like to get this mySql query:
SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6)
我写的其余api是这样的:
The rest api that I wrote is like this:
http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&filter[where][and][0][property2]=6
环回 json 翻译似乎是正确的:
The loopback json translation seems to be correct:
{
"or": [
{
"property1": 11
},
{
"property1": 13
}
],
"and": [
{
"property2": 6
}
]
}
但是在 mySql 上的翻译查询是:
But the translated query on mySql is:
SELECT * FROM `data` WHERE (`property1`=11) OR (`property1`=13) AND (`property2`=6)
怎么了?
推荐答案
正确的过滤器如下:
{
"and": [
{
"property2": 6
} ,
{
"or": [
{
"property1": 11
},
{
"property1": 13
}
] }
]
}
这篇关于Strongloop:用[and]和[or]条件一起过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文