在不使用索引的情况下更新 mongdb 中的二级嵌入式数组? [英] Updating second level embedded array in mongdb without using index?

查看:30
本文介绍了在不使用索引的情况下更新 mongdb 中的二级嵌入式数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mongodb 中有以下文档

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
            }]
     }]
  }

我想更新嵌入在 TktDetail 数组中的 Qty 数组中的 1-Aug 值.

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}});

任何帮助都会很棒.

推荐答案

这目前无法在单个调用中实现,但您可以观看以下 JIRA:https://jira.mongodb.org/browse/SERVER-831 希望它可能适用于 2.5(2.6 稳定版).

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).

这篇关于在不使用索引的情况下更新 mongdb 中的二级嵌入式数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆