数组更新运算符$(更新)不起作用 [英] Array update operator $ (update) doesn't work
本文介绍了数组更新运算符$(更新)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
来自https://docs.mongodb.com/v3.6/reference/operator/update/positional/的示例可在我的本地MongoDB上运行,而在Azure上失败.
有这样的文件的学生收藏
Hi!
An example from https://docs.mongodb.com/v3.6/reference/operator/update/positional/ works on my local MongoDB and fails on Azure.
There is a students collection with such document
{
_id: 4,
grades: [
{ grade: 80, mean: 75, std: 8 },
{ grade: 85, mean: 90, std: 5 },
{ grade: 85, mean: 85, std: 8 }
]
}
还有一个查询
And a query
db.students.updateOne(
{ _id: 4, "grades.grade": 85 },
{ $set: { "grades.$.std" : 6 } }
)
虽然更新在本地成功完成,但是在Azure上我得到了这个信息:
While update succeeds locally, on Azure i get this:
WriteError({
"index" : 0,
"code" : 57,
"errmsg" : "The dollar ($) prefixed field 'grades.$.std' in 'grades.$.std' is not valid for storage.",
"op" : {
"q" : {
"_id" : 4,
"grades.grade" : 85
},
"u" : {
"$set" : {
"grades.$.std" : 6
}
},
"multi" : false,
"upsert" : false
}
})
推荐答案
我建议您投票赞成另一位Azure客户提交的想法.
https://feedback.azure.com/forums/263030-azure-cosmos-db /suggestions/6693091-可以在文档中进行部分更新
您在这些论坛中分享的所有反馈都将受到监视和审查负责构建Azure的Microsoft工程团队.
这篇关于数组更新运算符$(更新)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文