英文:
Replace specific element in array using partial document update in Cosmos DB without knowing it's index
问题
可以在 Cosmos 文档中使用部分文档更新来替换数组中特定元素而无需知道其索引吗?
给定示例的 JSON 文档,是否可以替换数组 "elements" 中名称为 "B" 的元素,而无需知道元素的索引,使用 Cosmos DB 中的部分文档更新?
{
"elements": [
{
"name": "A",
"value": 5
},
{
"name": "B",
"value": 3
},
{
"name": "C",
"value": 8
}
]
}
在Microsoft文档中未找到相关信息。
英文:
Is it possible to replace a specific element in an array in a Cosmos document using partial document update without knowing it's index?
Given the example json document, is it possible to replace the element in the array "elements" where name is "B", without knowing the index of the element using a partial document update in Cosmos DB?
{
"elements": [
{
"name": "A",
"value": 5
},
{
"name": "B",
"value": 3
},
{
"name": "C",
"value": 8
}
]
}
No information found in the Microsoft documentation
答案1
得分: 1
不,PATCH 要求您传递需要更新的对象的特定索引,文档中有提到1。我们正在努力启用这一特定功能,但作为替代方案,您应该考虑条件性修补。
英文:
No, PATCH requires you to pass the specific index of the object needs to be updated and it is mentioned in the documentation. We are working on enabling this particular feature, However as an alternative, you should look at Conditional Patch
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论