在风帆和水线中使用AND和OR子句的混合

Muh*_*min 3 sails.js waterline

如何在Sailsjs及其ORM水线中使用OR和AND子句?例如,我有一张书桌

 _______________________________________
| book_name | author   | free  | public |  
 _______________________________________
| Book-A    | Author-1 | false | true   |
 ---------------------------------------
| Book-B    | Author-1 | true  | true   |
 ---------------------------------------
| Book-C    | Author-1 | false | false  |
 ---------------------------------------
| Book-D    | Author-2 | true  | true   |
 ---------------------------------------
Run Code Online (Sandbox Code Playgroud)

我想获得作者-1的书籍,这些书籍是公开的或免费的,即Book-A和Book-B.如何使用Sails.js编写此查询

Jim*_*rts 5

以下查询也应该有效:

const books = yield Book.find().where({
  author: 'Author-1',
  or: [{
    free: true,
  }, {
    public: true,
  }],
});
Run Code Online (Sandbox Code Playgroud)