I am using the mongoid any_of query to find a lead with an appointment status_selected of "option1" OR a lead source_selected of "opt4". I have a lead document that fits this criteria:
> db.leads.find()
{ "_id" : ObjectId("556e4f576d61638512060000"), "appointment status_selected" : "option1", "lead source_selected" : "opt2", "updated_at" : ISODate("2015-06-03T00:50:31.029Z"), "created_at" : ISODate("2015-06-03T00:50:31.029Z") }
However, when I query using the mongoid query helpers, I get no results:
Lead.where({"appointment status_selected" => "option1"}).any_of({"lead source_selected" => "opt4" }).first
# => nil
This is what moped shows:
MOPED: 127.0.0.1:27017 QUERY database=core_development collection=leads selector={"appointment status_selected"=>"option1", "$or"=>[{"lead source_selected"=>"opt4"}]} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 13.7830ms MOPED: 127.0.0.1:27017 QUERY database=core_development collection=leads selector={"appointment status_selected"=>"option1", "$or"=>[{"lead source_selected"=>"opt4"}]} flags=[] limit=0 skip=0 batch_size=nil fields=nil runtime: 4.1470ms
Why is Mongoid not returning that record in MongoDB?