Mongoid matches? does not support $elemMatch

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      class Subdoc
        include Mongoid::Document
        embedded_in :foo
        field :a
        field :b
      end
      class Foo
        include Mongoid::Document
        embeds_many :subdocs
      end
      
      f = Foo.new
      f.subdocs.new(:a => 1, :b => 1)
      
      f.subdocs.where(:a => 1).first
      => #<Subdoc _id: 57912b932774e24d68ce123f, a: 1, b: 1>
      
      f.subdocs.where(:$elemMatch => {:a => 1}).first
      => nil
      

      I know that matches? isn't a full implementation of the MongoDB query evaluation engine, but this is fairly easy to support:

      https://github.com/mongodb/mongoid/pull/4300

              Assignee:
              Emily Stolfo (Inactive)
              Reporter:
              Jon Hyman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: