Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4088

pluck not working as expected on subdocument

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      I have a Mongo shell query working and I'm trying to duplicate it with Mongoid.
      Here is what works in the Mongo shell
      {{db.getCollection('accounts').find(

      {field1: 'test'}

      ,

      {'field1': 1, 'subdocs.field2': 1}

      )}}
      I'm thinking the pluck method should work, but it always returns nil for subdocs.field2 even though there is a value in the document.
      >>Account.where(field1: 'test').pluck(:field1, 'subdocs.field2')
      [['test', nil], ['test', nil]]
      Should this work?

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            steveo7 steveo7
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: