bulk_delete: Delete a set of documents from an Azure Cosmos DB container

Description Usage Arguments Details Value See Also Examples

View source: R/bulk.R

Description

Delete a set of documents from an Azure Cosmos DB container

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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.

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.

Value

The number of rows deleted.

See Also

bulk_import, cosmos_container

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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 dplyr
bulk_import(cont, dplyr::starwars)

# deleting a subset of documents
bulk_delete(cont, "select * from mycontainer c where c.gender = 'masculine'")

# deleting documents for a specific partition key value
bulk_delete(cont, "select * from mycontainer", partition_key="male")

# deleting all documents
bulk_delete(cont, "select * from mycontainer")


## End(Not run)

AzureCosmosR documentation built on Jan. 19, 2021, 1:07 a.m.