【问题标题】:Strongloop Looback Where Or filter in REST syntaxStrongloop Loopback Where Or 以 REST 语法过滤
【发布时间】:2016-06-22 10:16:59
【问题描述】:

我需要查询where descr like 'xxx' or short_descr like 'xxx'

我知道how to do 它使用:

{"where": {
      "or": [
        {"description": {"like": "xxx"}},
        {"short_description": {"like": "xxx"}}
      }
    }
}

但需要在 REST 语法中添加查询参数。

我正在尝试:

params['filter[where][or]'] = JSON.stringify([
                { "description": { "like": "xxx" } },
                { "short_description": { "like": "xxx" } }
              ])

The or operator has invalid clauses 结果。

【问题讨论】:

    标签: loopbackjs strongloop


    【解决方案1】:

    这里是一个例子(我用'desc'而不是'description'):

    http://localhost:3000/api/cats?filter[where][or][0][desc][like]=foo&filter[where][or][1][short_desc][like]=goo

    所以重要的部分是这样的:

    • 首先,您需要为 OR 子句的每个部分指定一个索引。注意第一个是 0,然后是 1。
    • 其次 - 嗯...我以为我还有更多,但仅此而已。

    有关 WHERE 过滤器的更多信息:https://docs.strongloop.com/display/LB/Where+filter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-06
      • 2020-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多