Skip to content

Instantly share code, notes, and snippets.

@benedikt
Last active December 18, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benedikt/5859066 to your computer and use it in GitHub Desktop.
Save benedikt/5859066 to your computer and use it in GitHub Desktop.
Is this a mongoid bug or a feature?
Model.elem_match(:embedded => { :a => 1, :b => 2 })
# => #<Mongoid::Criteria
# selector: {"embedded"=>{"$elemMatch"=>{:a=>1, :b=>2}}}
# options: {}
# class: Model
# embedded: false>
Model.elem_match(:embedded => { :a => 1 }).elem_match(:embedded => { :b => 2 })
# => #<Mongoid::Criteria
# selector: {"embedded"=>{"$elemMatch"=>{:b=>2}}}
# options: {}
# class: Model
# embedded: false>
@cpuguy83
Copy link

I would expect that to be expected behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment