Here is the code I use to delete a document:
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)
}
})
It works for a collection with partition key. For such a case I pass ['myPartitionKey']
for partitionKeys
variable. But I am lost for collection that does not use partitioning.
A number of issues and PRs in azure-documentdb-node and vscode-cosmosdb cross reference each other.
What I also did not understand is why instead of fixing documentdb npm package repository the fixes are made in vscode-cosmosdb.
This issue mentions the problem and here possible solution is shared.
Although I tried passing null, undefined and {}
, nothing worked. I am getting:
Partition key provided either doesn't correspond to definition in the collection or doesn't match partition key field values specified in the document.
{}
as second parameter should work. This is how we're using in our code.client.deleteDocument(docUrl, {}, (err) => {})
. – Gaurav Mantri1.14.5
. – Farrukh Normuradov