deleteDocuments: Deletes documents in a collection, either all or only those...

Description Usage Arguments Value Examples

Description

Note: As this function deletes each document one by one, it can take very long to do the deletions. In some cases, it is a better approach to delete and recreate the collection.

Usage

1
2
deleteDocuments(connectionInfo, predicate = "", partitionKey = "",
  consistencyLevel = "", sessionToken = "", userAgent = "")

Arguments

connectionInfo

A DocumentDB connection info object generated with getDocumentDBConnectionInfo().

predicate

Optional. The predicate which has to be satisfied. Example: "c.machineId IN ('Machine 1', 'Machine 2')" deletes all documents of machine 1 and 2. Default is "", ie. all documents in the collection are deleted.

partitionKey

Optional. Can be used to limit the operation to a certain partition.

consistencyLevel

Optional. The consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest). The override must be the same or weaker than the account's configured consistency level.

sessionToken

Optional. A string token used with session level consistency. For more information, see Using consistency levels in DocumentDB.

userAgent

Optional. A string that specifies the client user agent performing the request. The recommended format is user agent name/version. For example, the official DocumentDB .NET SDK sets the User-Agent string to Microsoft.Document.Client/1.0.0.0. A custom user-agent could be something like ContosoMarketingApp/1.0.0.

Value

Some information extracted from the REST API responses such as (aggregated) request charges and latest session token.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# load the documentdbr package
library(documentdbr)

# get a DocumentDBConnectionInfo object
myCollection <- getDocumentDBConnectionInfo(
  accountUrl = "https://somedocumentdbaccount.documents.azure.com",
  primaryOrSecondaryKey = "t0C36UstTJ4c6vdkFyImkaoB6L1yeQidadg6wasSwmaK2s8JxFbEXQ0e3AW9KE1xQqmOn0WtOi3lxloStmSeeg==",
  databaseId = "MyDatabaseId",
  collectionId = "MyCollectionId"
)

# delete all documents from the collection and print the request charge
deleteResult <- deleteDocuments(myCollection)
print(deleteResult$requestCharge)

# delete all documents where value1 is < 0.5 and print the request charge
deleteResult <- deleteDocuments(myCollection, predicate = "c.value1 < 0.5")
print(deleteResult$requestCharge)

timoklimmer/documentdbr documentation built on May 31, 2019, 2:29 p.m.