0

I am having following document in mongodb

 {
   "CompanyCode" : "xyz",
   "TktDetail" : [
        {
        "Type" : "ab yyy (123+4)",
         "Qty" : [{
            "1-Aug" : 48
             }, {
              "1-Sep" : 42
            }]
         }, 
         {
        "Type" : "bc xyz (123+4)",
         "Qty" : [{
        "10-Aug" : 2
              }, {
             "10-Sep" : 2
              }, {
               "11-Sep" : 2
            }]
     }]
  }

I want to update the 1-Aug value in the Qty array which is embedded inside the TktDetail array.

I had tried with the following query.Its not updating

 db.test.update({"CompanyCode":"xyz","TktDetail.type":"ab yyy (123+4)"},{$set:{"TktDetail.$.Qty.$.1-Aug":55}});

Any help will be great.

1

1 Answer 1

1

This is currently not possible in a single call but here is a JIRA you can watch: https://jira.mongodb.org/browse/SERVER-831 hopefully it might be in for 2.5 (2.6 stable).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.