Ruby on rails 如何在Mongoid 3中使用嵌套and或or查询
在Mongoid的前一个版本中,我会写道:Ruby on rails 如何在Mongoid 3中使用嵌套and或or查询,ruby-on-rails,mongoid,Ruby On Rails,Mongoid,在Mongoid的前一个版本中,我会写道: Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]}, {"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}]) 我应该如何在Mongoid 3.0.13中编写它?您可能不需要这些AND 试试这个: Clothes.or({_t
Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]},
{"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}])
我应该如何在Mongoid 3.0.13中编写它?您可能不需要这些AND 试试这个:
Clothes.or({_type: "Shoes", is_secondhand: false},
{_type: "Shirts", is_secondhand: true})
Mongoid 3中发生了很多变化,大多数查询选择器都被移到了原点。看一看这张照片