2
我想更新现有的文档,其中有一个空值的字段,我得到以下错误。
文件:
{
"_id" : ObjectId("582299f71e21dbf65027325e"),
"b" : "5555",
"f" : null
}
查询:
db.getCollection('temp').update({"b":"5555"},{"$set":{"f.1.b":1,"f.2.b":2}})
错误:
WriteResult({
"nMatched" : 0,
"nUpserted" : 0,
"nModified" : 0,
"writeError" : {
"code" : 16837,
"errmsg" : "cannot use the part (f of f.1.b) to traverse the element ({f: null})"
}
})
谁能告诉我,为什么它是不更新文档中的值。
谢谢。
它工作正常,如果我的目标是零和在有些值已经存在的情况下,它将取代现有的对象。感谢您的回答。 – Prabhakaran
欢迎你,如果你有解决方案,你可以打勾标记这个答案,感谢 –