Sails Waterline "Or" 条款不起作用
Sails Waterline "Or" clause not working
我尝试了很多时间来弄清楚如何在 sails 中使用 OR 子句但没有成功。
我正在使用 Sails-MySql 适配器。
你们中有人做过这样的事吗?我将不胜感激。
基本上这就是我想要做的:
对一组字段执行 OR 子句,同时对另一组字段执行 AND。
像这样:
FdbDevice
.find()
.where(or:
[
{ deviceCategory: “cardiology valve bioprosthesis” },
{ deviceCategory: “nephrology haemodialysis catheter” }
]
})
.where(
{ catalogNumber : “Z286004” },
{ modelNumber: “Z286004” }
)
.exec
在这种特殊情况下,我会这样做:
// Each element in the array is treated as 'or'
var possibleDeviceCategories = [
'cardiology valve bioprosthesis',
'nephrology haemodialysis catheter'
];
FdbDevice
.find({
deviceCategory: possibleDeviceCategories,
catalogNumber: 'Z286004',
modelNumber: 'Z286004'
})
.exec(cb);
查看 the docs 了解有关 Waterline 查询语言的更多信息。
你可以尝试类似的东西,进入发现:
FdbDevice
.find({or:
[
{ deviceCategory: “cardiology valve bioprosthesis” },
{ deviceCategory: “nephrology haemodialysis catheter” }
]
})
.where(
{ catalogNumber : “Z286004” },
{ modelNumber: “Z286004” }
)
我尝试了很多时间来弄清楚如何在 sails 中使用 OR 子句但没有成功。
我正在使用 Sails-MySql 适配器。
你们中有人做过这样的事吗?我将不胜感激。
基本上这就是我想要做的:
对一组字段执行 OR 子句,同时对另一组字段执行 AND。
像这样:
FdbDevice
.find()
.where(or:
[
{ deviceCategory: “cardiology valve bioprosthesis” },
{ deviceCategory: “nephrology haemodialysis catheter” }
]
})
.where(
{ catalogNumber : “Z286004” },
{ modelNumber: “Z286004” }
)
.exec
在这种特殊情况下,我会这样做:
// Each element in the array is treated as 'or'
var possibleDeviceCategories = [
'cardiology valve bioprosthesis',
'nephrology haemodialysis catheter'
];
FdbDevice
.find({
deviceCategory: possibleDeviceCategories,
catalogNumber: 'Z286004',
modelNumber: 'Z286004'
})
.exec(cb);
查看 the docs 了解有关 Waterline 查询语言的更多信息。
你可以尝试类似的东西,进入发现:
FdbDevice
.find({or:
[
{ deviceCategory: “cardiology valve bioprosthesis” },
{ deviceCategory: “nephrology haemodialysis catheter” }
]
})
.where(
{ catalogNumber : “Z286004” },
{ modelNumber: “Z286004” }
)