更新时间:2022-10-15 08:53:18
Cars.filter(功能(车){
返回car.get(模特)=== 1998年||
car.get(色)===黑||
car.get(使)===本田;
});
I have searched for this for quite some time but could not get a way to have a where clause with or condition. For example if I have a collection Cars
and I try to do the following:
Cars.where({
model: 1998,
color: 'Black',
make: 'Honda'
})
So what the above will do is search for a car
whose model
is 1998
AND color
is Black
AND make
is Honda
.
But I require a way to get cars
which have either of the three conditions true.
Cars.filter(function(car) {
return car.get("model") === 1998 ||
car.get("color") === "Black" ||
car.get("make") === "Honda";
});