1

I can't write update request for my config, can you help me? I have many brackets. I am using 'putty'. There is my config:

{"_id" : ObjectId("567964b88946119e1ebb8bbc"),
"minv": 43,
"maxv": 1000,
"c": "default",
"p": [
      {
       "c": "fragment1",
       "n": [
              {
                "pr": 100,
                "c": "am"
              }
           ]
      },
       {
       "c": "fragment2",
       "n": [
              {
                "pr": 33,
                "c": "am"
              },
                  {
                "pr": 33,
                "c": "pl"
              },
                  {
                "pr": 34,
                "c": "mp"
              }
           ]
      }
]
}

My update request does not work:

db.trtconfigs.update(
{
'_id':ObjectId('567964b88946119e1ebb8bbc'),
'p.c':'fragment2',
'p.n.c':'am'
},{'$set':{'p.n.pr':20}}
)

What is wrong?

Community
  • 1
  • 1
  • You cannot query this structure all in one go since MongoDB does not yet support nested $ operators https://jira.mongodb.org/browse/SERVER-831 – Sammaye Jan 15 '16 at 11:16
  • So, if I understand true - I can't update one parameter, only all child object, can't it? – Гром Андрій Jan 15 '16 at 12:05
  • atm MongoDB can only update one child object one level deep – Sammaye Jan 15 '16 at 12:13
  • db.adconfigs.update( {'_id':ObjectId('56815d29e9afcc908ef5af97')}, {'$set': {'p.n.0': {"c" : "fragment1","n" : [{"pr" : 90, "c" : "am"}] } } }) and i have error: "writeError" : { "code" : 16837, "errmsg" : "cannot use the part (p of p.n.0) to traverse the element ..... my config} – Гром Андрій Jan 15 '16 at 13:58

0 Answers0