2 u010236550 u010236550 于 2017.09.11 17:24 提问

mongo 内嵌数据更新?

{
"_id" : ObjectId("59ad24e7dd787405b6c42baf"),
"cardInfo" : [
{
"storyUuid" : "46f77560-d743-4b86-9030-19a2173efbb0",
"cardTime" : "1504877683599",
“flag”:“false”
},
{
"storyUuid" : "c8f11b86-27bf-4916-8a24-8f0d13fd4ae5",
"cardTime" : "1505044513946",
“flag”:“false”
}
],
"continuousMakeCard" : 1,
"createTimestamp" : NumberLong(1504519399652),
"uuid" : "4f7330d6-cba9-478c-8e87-b97f2a01cd38"
}

1: 上面是一个json 数据比如我想要更新uuid=4f7330d6-cba9-478c-8e87-b97f2a01cd38并且cardTime=1504877683599更新flag=true,麻烦这个如何写呢?其他的保持不变。

1个回答

oyljerry
oyljerry   Ds   Rxr 2017.09.11 18:24
 db.books.update(
   { 
     "uuid": "4f7330d6-cba9-478c-8e87-b97f2a01cd38",
     "cardInfo.cardTime" : "1504877683599"
     },
   {
     "cardInfo.flag": "true"
   }
)
u010236550
u010236550 db.getCollection('makeCard').update({"uuid":"dd663943-ec38-495d-b778-c56590ad0d1f", "cardInfo.cardTime":"1504493742709"},{"cardInfo.stat":"true"}) 报错了:Error: can't have . in field names [cardInfo.stat] :
2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片