How can I use OR and AND clause in Sailsjs and its ORM Waterline? For example I have a table of books
_______________________________________
| book_name |
The following query should also work:
const books = yield Book.find().where({
author: 'Author-1',
or: [{
free: true,
}, {
public: true,
}],
});
For doing so we can use the where api of Waterline, following is an example
Book.find().where( { or : [ { free : true }, { public: true } ] })
.where( { author : "Author-1" } )
.exec( function (err, books) {
//Books will be an array containing all the books that matches this criteria
//Some code here
}
let booksResult=await Book.find().
where({author: "Author-1",
or: [{ free: true }, { public: true }]
});