azure-cosmosdbazure-cosmosdb-mongoapi

How to delete all data in a partition?


I have a CosmosDB collection with a number of different partitions. I want to delete all of the data in one of the partitions so I tried to run the command:

db.myCollection.deleteAll({PartitionKey: 'pop-9q'})

Where PartitionKey is the field that I partition/shard based on. But when I execute this it returns the not very helpful message:

ERROR: An Error has occurred

Why would I be getting this message and how can I either get more details on the cause or find a resolution?


Solution

  • Currently, at this time, you are unable to perform a bulk delete. Please Up Vote and Comment on this functionality: Add the ability to delete ALL data in a partition

    Additionally, which API are you consuming? For Gremlin API you could execute something like the following: g.V().drop()