Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter Mongo查询以更新字段_Codeigniter_Mongodb - Fatal编程技术网

Codeigniter Mongo查询以更新字段

Codeigniter Mongo查询以更新字段,codeigniter,mongodb,Codeigniter,Mongodb,我正在使用Mongo library(alex bibly)和codeignitor,我的收藏如下 { chart:{ "LL":[ { "isEnable":true, "userName":"Nishchit Dhanani" } ] } } 我想更新isEnable=false 感谢您的帮助。首先,您的

我正在使用Mongo library(alex bibly)和codeignitor,我的收藏如下

{
  chart:{
         "LL":[
                { "isEnable":true,
                  "userName":"Nishchit Dhanani"
                }
              ]           
        }
}
我想更新isEnable=false


感谢您的帮助。

首先,您的JSON文档中有一个错误。字典中不能有键值

因此,您的JSON应该如下所示:

{
    "_id" : ObjectId("526e0d7ef6eca1c46462dfb7"),  // I added this ID for querying. You do not need it
    "chart" : {
        "LL" : {
            "isEnable" : false,
            "userName" : "Nishchit Dhanani"
        }
    }
}
db.test.update(
  {"chart.LL.isEnable" : false},
  {$set : {"chart.LL.$.isEnable" : false}}
)
要做你需要的事,你必须使用

通过新的修改,您需要执行以下操作:

{
    "_id" : ObjectId("526e0d7ef6eca1c46462dfb7"),  // I added this ID for querying. You do not need it
    "chart" : {
        "LL" : {
            "isEnable" : false,
            "userName" : "Nishchit Dhanani"
        }
    }
}
db.test.update(
  {"chart.LL.isEnable" : false},
  {$set : {"chart.LL.$.isEnable" : false}}
)

你是对的,但我在alex bibly的Mongo图书馆使用codigniter。这有可能吗??