Organizational Research By

Surprising Reserch Topic

update embedded object inside array inside array in mongodb


update embedded object inside array inside array in mongodb  using -'mongodb,mongodb-query'

I have document like

{
    id : 100,
    heros:[
        {
           nickname : "test",
           spells : [
             {spell_id : 61, level : 1},
             {spell_id : 1, level : 2}
           ]
        }
    ]
}


I can't $set spell's level : 3 with spell_id : 1 inside spells that inside heros with nickname "test. I tried this query:

db.test.update({"heros.nickname":"test", "heros.spells.spell_id":1},
{$set:{"heros.spells.$.level":3}});


Errror i see is


  can't append to array using string field name [spells]
  Thanks for help.

    
asked Oct 6, 2015 by devkumargupta
0 votes
8 views



Related Hot Questions



Government Jobs Opening


...