Strongloop:用[and]和[or]条件一起过滤数据

2023-12-27

我正在尝试使用“and”和“or”条件过滤数据。 我想得到这个 mySql 查询:

SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6)

我写的其余 api 是这样的:

http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&filter[where][and][0][property2]=6

环回 json 翻译似乎是正确的:

{                                            
    "or": [                              
            {                            
                    "property1": 11      
            },                           
            {                            
                    "property1": 13      
            }                            
    ],                                   
    "and": [                             
            {                            
                    "property2": 6     
            }                            
    ]                                    
}

但是 mySql 上的翻译查询是:

SELECT * FROM `data` WHERE (`property1`=11) OR (`property1`=13) AND (`property2`=6)

怎么了?


正确的过滤器是这样的:

{     
    "and": [
        {                            
          "property2": 6     
        } ,
        {
        "or": [                              
            {                            
                    "property1": 11      
            },                           
            {                            
                    "property1": 13      
            }                            
    ]   }    
    ]                              
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Strongloop:用[and]和[or]条件一起过滤数据 的相关文章

随机推荐