Sails.js:水线或filter不工作
我正在开发一个sails.js应用程序使用默认水线 。
我有一系列的类别和位置,如下所示。
var categoryOrFilter = [1,2,3]; var locationsOrFilter = [8,9,10];
我正在尝试在我的model
上编写一个where
,它将过滤属于categoryOrFilter
中的至less一个categoryOrFilter
以及位于locations
中的至less一个locations
的模型项目。
我的模型如下所示。
attributes: { category: { model: 'category' }, location: { model: 'location' } }
我写了我的查询如下所示。
Model.find() .where({ or: [{ "category": categoryOrFilter }] }) .where({ or: [{ "location": locationsOrFilter }] }) .exec(function (err, modelItem) { //Some logic });
我的categoryOrFilter值不被考虑。 我的locationOrFilter值工作完美。
我究竟做错了什么?
第二个where和'or'不需要标准部分之间的默认运算符是AND,对于单个标准部分中的数组元素,它是IN
Model.find() .where({ "category": categoryOrFilter, "location": locationsOrFilter }) .exec(function (err, modelItem) { // Some logic });