Azure CosmosDB 数据触发器未进行实际更新
Azure CosmosDB Data Trigger not taking actual updates
我已经使用 CosmosDB 触发器模板创建了一个 Azure 函数:this link
工作正常,我可以看到更新从我在 Cosmos DB 中创建的 Collection 流入。
现在的问题是,我只想要那些有实际更新的文档。目前,如果我使用代码更新文档,它会更新它的时间戳,并且文档正在更新中。虽然没有实际的数据更新。
我的问题:
- 如何只获取Actual Updated文档(只获取json字段被修改的文档)?
- 我怎样才能同时跟踪已删除的文档?他们也没有流向这里??
1) 由于对文档的任何推送都会更新 - internally managed - _ts
属性,这仍然是对整个文档的更改。如果您更改了文件的用户数据,这里无关紧要。更改提要不知道这种区别。因此,您也将始终在更改源中看到这些更新。
2) 删除不会添加到更改源中,但有一个可能的解决方法:
Currently change feed doesn’t log deletes. [...] you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted.
https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed#change-feed-and-different-operations
我已经使用 CosmosDB 触发器模板创建了一个 Azure 函数:this link
工作正常,我可以看到更新从我在 Cosmos DB 中创建的 Collection 流入。
现在的问题是,我只想要那些有实际更新的文档。目前,如果我使用代码更新文档,它会更新它的时间戳,并且文档正在更新中。虽然没有实际的数据更新。
我的问题:
- 如何只获取Actual Updated文档(只获取json字段被修改的文档)?
- 我怎样才能同时跟踪已删除的文档?他们也没有流向这里??
1) 由于对文档的任何推送都会更新 - internally managed - _ts
属性,这仍然是对整个文档的更改。如果您更改了文件的用户数据,这里无关紧要。更改提要不知道这种区别。因此,您也将始终在更改源中看到这些更新。
2) 删除不会添加到更改源中,但有一个可能的解决方法:
Currently change feed doesn’t log deletes. [...] you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted.
https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed#change-feed-and-different-operations