Using mix of AND and OR clause in sails and waterline

后端 未结 3 1587
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 11:22

How can I use OR and AND clause in Sailsjs and its ORM Waterline? For example I have a table of books

 _______________________________________
| book_name |          


        
3条回答
  •  醉酒成梦
    2021-01-14 11:49

    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
        }
    

提交回复
热议问题