2012-11-19 34 views
0

嵌套和或查詢在Mongoid前版本我會寫:如何使用Mongoid 3

Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]}, 
         {"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}]) 

我應該怎麼寫,在Mongoid 3.0.13?

回答

1

你可能不需要那些

試試這個:

Clothes.or({_type: "Shoes", is_secondhand: false}, 
      {_type: "Shirts", is_secondhand: true}) 

很多已經Mongoid 3改變,大部分的查詢選擇器被移動到原點。看看Origin documentation

+0

它的工作原理,非常感謝。:) – alikewmk