这是我用来删除文档的代码:
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包存储库而不是修复documentdb npm包存储库 .
This问题提到了问题并且here可能的解决方案是共享的 .
虽然我试过传递 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.
1 回答
我为你做了两次测试 . 我的documentdb npm包版本是
1.14.2
First situation: 想删除分区集合中未定义分区键的文档 .
sample documents:
delete code:
Second situation: 想删除非分区集合中未定义分区键的文档 .
sample documents:
delete code:
希望它能帮到你 .