如何在AzureDb中强制替换文档? [英] How to force a document replace in AzureDb?

查看:62
本文介绍了如何在AzureDb中强制替换文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 
我遇到了尝试用另一个文档替换文档的问题.通过使用CreateDocumentAsync()存储对象来创建原始文档.除了添加的属性外,用于替换它的对象是相似的(名称,类型,..).结果 对ReplaceDocumentAsync()的调用确定,这意味着文档已被替换.使用Azure Storage Explorer进行检查,更改将反映在数据库中.

但是,在阅读文档时,它会还原为较早的文档,丢失所有更改.这可以在读取结果中看到,也可以在Azure Storage Explorer中看到.

复制步骤:
-将对象A保存到CosmosDb
-change object A属性值,替换CosmosDb中的文档
=>一切都好
读取来自CosmosDb的文档
=>一切正常,数据反映出更改后的值
-change object通过添加新属性定义,替换CosmosDb中的文档
=>全部(貌似)好
读取来自CosmosDb的文档
=>更改丢失,文档恢复为不包含添加的属性的早期版本


在这种使用中,除了单独删除旧文档并创建新文档之外,是否有办法强制替换文档(包括对任何CosmosDb内部数据的更新,这可能会导致上述行为)?

-Jarno

  Hi,
I've come across an issue trying to replace a document with another. The original document is created by storing an object using CreateDocumentAsync(). The object to replace it is similar (same name, type,..), with the exception of an added property. The result for ReplaceDocumentAsync() call is OK, implying the the document was replaced. Checking with Azure Storage Explorer, the changes are reflected in the database. 

However, when reading the document, it gets reverted back to the earlier one, losing all the changes. This can be seen in the read result and also with Azure Storage Explorer.

Steps to reproduce:
-save object A to CosmosDb
-change object A property values, replace document in CosmosDb
=> all OK
-read document from CosmosDb
=> all OK, data reflects the changed values
-change object A definition by adding a new property, replace document in CosmosDb
=> all (seemingly) OK
-read document from CosmosDb
=> changes are lost, document is reverted to an earlier version not containing the added property


In such use, is there a way to force a document replace (including an update to any CosmosDb internal data, which may cause the said behavior) other than by separately deleting the old document and creating a new one?

-Jarno

推荐答案

Jarno,

Hi Jarno,

我相信您遇到了不支持部分更新的Cosmos DB限制.

I believe you are running into the Cosmos DB limitation of partial updates not being supported. 

能够对文档进行部分更新

请在用户语音"论坛中对该功能进行投票.

Please up vote this functionality in the User Voice forum.

此致

迈克


这篇关于如何在AzureDb中强制替换文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆