Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8834

MongoDB return fields from subdocuments in an array

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I have a document such as:

      {_id: ObjectId("512fe1e5b9912a714eef4e54"),
      items: [

      {type:'test', name:'my first object'}

      ,

      {type:'test', name:'my second object'}

      ]}

      Basically i need to list all the names in my items array something similar to:

      db.log.findOne({_id:ObjectId("512fe1e5b9912a714eef4e54")},{'items.$':{name:1}});

      Is there another way to do it ? Or is it even planned/discussed somewhere ?

            Assignee:
            ian@mongodb.com Ian Whalen (Inactive)
            Reporter:
            kurteknikk Kurt Agius
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: