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

update nest array item bug

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.1, 1.5.0
    • Affects Version/s: 1.4.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Linux tanglive.com 2.6.9-78.ELsmp #1 SMP Fri Jul 25 00:04:28 EDT 2008 i686 i686 i386 GNU/Linux

      > db.foo.insert(

      {"items":[null,null,null,null]}

      )
      > db.foo.find()

      { "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" : [ null, null, null, null ] }

      > db.foo.update({_id:ObjectId("4bac322669b89c9179dc9976")},{$set:{"items.0":

      {itemId:1,amount:9000}

      }})
      > db.foo.find()
      { "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" :
      [

      { "itemId" : 1, "amount" : 9000 }

      , null, null, null ] }
      > db.foo.update({_id:ObjectId("4bac322669b89c9179dc9976")},{$inc:

      {"items.0.amount":1000}

      ,$set:{"items.1":

      {itemId:1,amount:1}

      }})
      > db.foo.find()
      { "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" : [

      { "itemId" : 1, "amount" : 9000 }

      ,

      { "itemId" : 1, "amount" : 1 }

      ,

      { "amount" : 1000 }

      ,
      null,
      null
      ] }
      >

      I hope that the result should be
      { "_id" : ObjectId("4bac322669b89c9179dc9976"), "items" : [

      { "itemId" : 1, "amount" : 10000 }

      ,

      { "itemId" : 1, "amount" : 1 }

      ,
      null,
      null,
      null
      ] }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            h2o0 Tony Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: