如何解决使用唯一键删除波斯菊文档,而无需先获取对象
我的对象看起来像这样:
{
"documentType":"doc","relatedKey": "Person1","Color": "blue","Street": "SomeStreet",}
分区键设置为/ documentType
UniqueKey 设置为/ documentType,/ relatedKey
现在如何发送分区键和 UniqueKey 直接删除文档?通过使用Cosmos API?
以下代码显示了我要实现的目标:
[HttpDelete]
[Route("{documentType}/{relatedKey}")]
public async Task<ActionResult<string>> DeleteDocument(string documentType,string relatedKey)
{
Document doc = await documentClient.DeleteDocumentAsync(String.Format("/dbs/{0}/colls/{1}/docs/{2}/{3}",database,collection,documentType,relatedKey),new RequestOptions { PartitionKey = new Microsoft.Azure.Documents.PartitionKey(documentType) });
return Ok("ExtensionDocument deleted");
}
我的主要困难是删除具有多个唯一键的对象,而不仅仅是PartitionKey
只有一个PartitionKey,我知道如何删除文档。
解决方法
您不能以这种方式删除文档。您必须使用文档ID和分区键。
删除的文档为here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。