MongoDB return fields from subdocuments in an array

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 Whalen (Inactive)
              Reporter:
              Kurt Agius
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: