【问题标题】:How can I make in sails a query with a where clause and a 'or pairs' clause如何使用 where 子句和“或对”子句进行查询
【发布时间】:2016-09-03 15:41:15
【问题描述】:

我需要在 Sails 中进行查询,需要将 where 子句与“或对”子句混合使用。 例如,结果必须是指定用户(用户:$scope.user.id)的所有记录,另外来自此记录,只有那些 field1 = cond1 OR field2 = cond2 ...

我在 MySQL 中使用 Sails。 谢谢。

【问题讨论】:

    标签: mysql sails.js


    【解决方案1】:

    让您开始使用 OR 查询:http://sailsjs.org/documentation/concepts/models-and-orm/query-language#?or-pairs

    Model.find({
      user_id: 'xy'
      or : [
        { name: 'walter' },
        { occupation: 'teacher' }
      ]
    })
    

    此查询将获取包含 user_id=xy 的所有记录,并使用 OR 查询另外过滤这些记录。

    【讨论】:

      猜你喜欢
      • 2018-08-01
      • 1970-01-01
      • 2014-01-17
      • 2017-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-05
      • 1970-01-01
      相关资源
      最近更新 更多