【发布时间】:2018-07-17 11:44:32
【问题描述】:
这是我用来删除文档的代码:
const CosmosDbClient = require('documentdb').DocumentClient
let client = new CosmosDbClient(URL, {
masterKey: KEY
})
client.deleteDocument(docUrl, {
partitionKey: partitionKeys
}, (err) => {
if (err) {
throw err
} else {
console.log('DELETED document ' + docUrl)
}
})
它适用于带有分区键的集合。对于这种情况,我将['myPartitionKey'] 传递给partitionKeys 变量。但是我迷失了不使用分区的集合。
azure-documentdb-node 和 vscode-cosmosdb 中的一些问题和 PR 相互交叉引用。
我也不明白为什么不修复 documentdb npm 包存储库,而是在 vscode-cosmosdb 中进行修复。
This issue 提到了问题,并分享了@987654322@ 可能的解决方案。
虽然我尝试传递null, undefined and {},但没有任何效果。我得到:
Partition key provided either doesn't correspond to definition in the collection or doesn't match partition key field values specified in the document.
【问题讨论】:
-
您的集合是分区集合,而您只是没有为要删除的文档提供分区键值,或者该集合不是分区集合?是哪一种?
-
@GauravMantri 我的收藏很小。我不使用分区。
-
那么我认为将
{}作为第二个参数传递应该可以。这就是我们在代码中使用的方式。client.deleteDocument(docUrl, {}, (err) => {}). -
在您发表评论后,我现在又试了一次。它返回带有上述问题中提到的消息的错误。我的 documentdb npm 包版本是
1.14.5。 -
@FarrukhNormuradov 嗨,现在有更新吗?
标签: node.js azure azure-cosmosdb