updates not working at deeper level of array/object

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Blocker - P1
    • None
    • Affects Version/s: 2.5.4
    • Component/s: Querying, Write Ops
    • None
    • Environment:
      all
    • Fully Compatible
    • ALL
    • Hide

      see description

      Show
      see description
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      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.

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

              Created:
              Updated:
              Resolved: