我有这个查询:
User.or( { name: 'John' }, { name: 'Sara' } ).or( { age: 17 }, { age: 18 } ) )
它返回下一个标准:
#<Mongoid::Criteria
selector: {"enabled"=>true, "$or"=>[{"name"=>"John"}, {"name"=>"Anoun"}, {"age"=>17}. {"age"=>18}]}
options: {}
class: User
embedded: false>
但我想做两个“或”之间的“和”,返回如下内容:
#<Mongoid::Criteria
selector: {"enabled"=>true, "$and"=>[
{"$or"=>[{"name"=>"John"}, {"name"=>"Anoun"}]},
{"$or"=>[{"age"=>17}, {"age"=>18}]}
] }
options: {}
class: User
embedded: false>
查询将如何?