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

updates not working at deeper level of array/object

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker - P1 Blocker - P1
    • None
    • 2.5.4
    • Querying, Write Ops
    • None
    • all
    • Fully Compatible
    • ALL
    • Hide

      see description

      Show
      see description

    Description

      FOR a given DOCUMENT, where i have a unique sub document, which i want to update ..

      {
       id:1,
       a:[
           {
              id:2,
              b:[
                  {
                      id:3,
                      c:[
                          {
                              id:4,
                              d:["x","y"]
                          },
                          {
                              id:5,
                              d:["p","q"]
                          }
                      ]
                  },
                  {
                      id:13,
                      c:[
                          {
                              id:14,
                              d:["w","q"]
                          },
                          {
                              id:15,
                              d:["i","j"]
                          }
                      ]
                  }           
              ]   
           }
       ]
      } 

      FOR this document you cannot update d to d:["x","y","z"] ;

      PROPOSED change to update using PLACEMARKERS $as : $1 / $2 to the matched location rather $elemMatch
      NOTE : this is the proposed change .. beeter ways could be provided.

      db.coll.update({
       id:1,
       a:[
           {
              id:2,
      	$as:1	
              b:[
                  {
                      id:3,
                      c:[
                          {
                              id:4,
      			$as:2			
      		    }
                         ]	
                    }
                 ]
              }
           ]     
      },
      {
         $addToSet:{$2:{"d":["z"]}}	
      }
      );

      PLEASE SEE $elemMatch or any other operator doesn't work here ..
      even if i have the unique path to my subdocument. Which matches a single element .. i cannot update.. this is the BIGGEST feature gap.

      Attachments

        Activity

          People

            Unassigned Unassigned
            shravanz shravan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: