如何在mongo数据库中配置数组的索引1处更新配置中'Enabled‘字段的值?
下面是我的Json数据。
{
"Configurations" : [
{
"Configuration" : {
"Host" : "",
"Port" : "1521",
"Enabled" : "true"
}
},
{
"Configuration" : {
"Host" : "",
"Port" : "",
"Enabled" : "true"
}
}
],
"Description" : "Check Database Server"
}有没有办法更新配置中启用字段的值??如何在Mongodba中配置数组的索引1处更新配置中'Enabled'字段的值?
我想要更新Configurations Array中第二个配置的Enabled字段值。
发布于 2015-04-23 15:04:57
像这样怎么样?
db.collection.update({},
{ "$set": { "Configurations.1.Configuration.Enabled": false }}
)发布于 2015-04-23 15:17:43
试试这个:
db.collection.update({
"Configurations": {
"$elemMatch": {
"Configuration.Port": "1521"
}
}
}, {
"$set": {
"Configurations.$.Configuration.Enabled": "false"
}
})https://stackoverflow.com/questions/29815638
复制相似问题