【问题标题】:Find all where parameter is within an array - Waterline查找参数在数组中的所有位置 - Waterline
【发布时间】:2017-06-08 20:08:54
【问题描述】:

在伪代码中就是这样

查找 outcodes 数组包含 NG1 的所有商家

我很难找到可行的方法,并且 waterline 在我尝试的所有操作中都会抛出 Invalid usage。

  Business.find({
    or:{outcodes: {contains: 'NG1 4RQ' }}
  })

作为参考,我的业务模型包含作为数组的输出代码:

  outcodes:       { type: 'array' },

有没有人能建议我如何做到这一点。我难住了。目前使用 SailsJS 和 Waterline ORM

【问题讨论】:

    标签: sails.js waterline sails-mongo


    【解决方案1】:

    or 不起作用,因为它需要是一个数组。只有 1 个条件,您不需要使用 or,但这里有一个使用 or 并在数组中搜索部分字符串的示例。

    Business.find({
      or: [ { outcodes: { contains: 'NG1' }}]
    }).exec(function(err, businesses){...});
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      • 2013-08-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多