【问题标题】:Write filter condition in StrongLoop with [and] and [or] conditions together用 [and] 和 [or] 条件一起在 StrongLoop 中编写过滤条件
【发布时间】:2016-07-13 19:14:15
【问题描述】:

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

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

我写的其余api过滤器是这样的:

filter[where][and][0][or][0][property1]=11&filter[where][and][0][or][1][propert‌​y1]=13&filter[where][and][1][property2]=6

我有这样的错误:

ER_BAD_FIELD_ERROR: Unknown column '[property1]' in 'where clause'

为什么我有错误?

【问题讨论】:

  • 请给出完整的代码片段
  • @arjunkori 我的完整请求 uri 是 localhost:4000/api/Datas/…‌​y1]=13&filter[where][and][1][property2]=6 我正在使用 get关于模型数据的方法和响应中我有一个错误 ER_BAD_FIELD_ERROR: Unknown column '[property1]' in 'where Clause'

标签: mysql node.js loopbackjs strongloop


【解决方案1】:

您的模型没有property1。请根据您的数据模型修改过滤器

【讨论】:

  • 谢谢@EbrahimPasbani,但我在我的模型数据中有property1,如果我离开或条件过滤器一切正常!
  • @J.Doe 请尝试不使用 REST api 的直接查询。如果它有效,那么可能 REST api 查询无法深入
  • 谢谢@Ebrahim,没有REST api,工作正常!
猜你喜欢
  • 1970-01-01
  • 2018-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多