以前のバージョンの Mongoid では、次のように書きます。
Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]},
{"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}])
Mongoid 3.0.13 ではどのように記述すればよいですか?
以前のバージョンの Mongoid では、次のように書きます。
Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]},
{"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}])
Mongoid 3.0.13 ではどのように記述すればよいですか?
あなたはおそらくそれらのandsを必要としないでしょう。
これを試して:
Clothes.or({_type: "Shoes", is_secondhand: false},
{_type: "Shirts", is_secondhand: true})
Mongoid 3では多くの変更が行われ、クエリセレクターのほとんどがOriginに移動されました。Originのドキュメントをご覧ください。