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

MongoDB return fields from subdocuments in an array

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      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 ?

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: