0

以前のバージョンの Mongoid では、次のように書きます。

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

Mongoid 3.0.13 ではどのように記述すればよいですか?

4

1 に答える 1

1

あなたはおそらくそれらのandsを必要としないでしょう。

これを試して:

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

Mongoid 3では多くの変更が行われ、クエリセレクターのほとんどがOriginに移動されました。Originのドキュメントをご覧ください。

于 2012-11-21T01:26:26.713 に答える