Delete a set of documents from an Azure Cosmos DB container
Delete a set of documents from an Azure Cosmos DB container
bulk_delete(container,...)## S3 method for class 'cosmos_container'bulk_delete( container, query, partition_key, procname ="_AzureCosmosR_bulkDelete", headers = list(),...)
Arguments
container: A Cosmos DB container object, as obtained by get_cosmos_container or create_cosmos_container.
query: A query specifying which documents to delete.
partition_key: Optionally, limit the deletion only to documents with this key value.
procname: The stored procedure name to use for the server-side import code. Change this if, for some reason, the default name is taken.
headers, ...: Optional arguments passed to lower-level functions.
Returns
The number of rows deleted.
Details
This is a convenience function to delete multiple documents from a container. It works by creating a stored procedure and then calling it with the supplied query as a parameter. This function is not meant for production use.
Examples
## Not run:endp <- cosmos_endpoint("https://myaccount.documents.azure.com:443/", key="mykey")db <- get_cosmos_database(endp,"mydatabase")cont <- create_cosmos_container(db,"mycontainer", partition_key="sex")# importing the Star Wars data from dplyrbulk_import(cont, dplyr::starwars)# deleting a subset of documentsbulk_delete(cont,"select * from mycontainer c where c.gender = 'masculine'")# deleting documents for a specific partition key valuebulk_delete(cont,"select * from mycontainer", partition_key="male")# deleting all documentsbulk_delete(cont,"select * from mycontainer")## End(Not run)