get_stored_procedure {AzureCosmosR} | R Documentation |
Methods for working with Azure Cosmos DB stored procedures
get_stored_procedure(object, ...)
## S3 method for class 'cosmos_container'
get_stored_procedure(object, procname, ...)
list_stored_procedures(object, ...)
create_stored_procedure(object, ...)
## S3 method for class 'cosmos_container'
create_stored_procedure(object, procname, body, ...)
exec_stored_procedure(object, ...)
## S3 method for class 'cosmos_container'
exec_stored_procedure(object, procname, parameters = list(), ...)
## S3 method for class 'cosmos_stored_procedure'
exec_stored_procedure(object, ...)
replace_stored_procedure(object, ...)
## S3 method for class 'cosmos_container'
replace_stored_procedure(object, procname, body, ...)
## S3 method for class 'cosmos_stored_procedure'
replace_stored_procedure(object, body, ...)
delete_stored_procedure(object, ...)
## S3 method for class 'cosmos_container'
delete_stored_procedure(object, procname, confirm = TRUE, ...)
## S3 method for class 'cosmos_stored_procedure'
delete_stored_procedure(object, ...)
object |
A Cosmos DB container object, as obtained by |
... |
Optional arguments passed to lower-level functions. |
procname |
The name of the stored procedure. |
body |
For |
parameters |
For |
confirm |
For |
These are methods for working with stored procedures in Azure Cosmos DB using the core (SQL) API. In the Cosmos DB model, stored procedures are written in JavaScript and associated with a container.
For get_stored_procedure
and create_stored_procedure
, an object of class cosmos_stored_procedure
. For list_stored_procedures
, a list of such objects.
## 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")
# a simple stored procedure
src <- 'function helloworld() {
var context = getContext();
var response = context.getResponse();
response.setBody("Hello, World");
}'
create_stored_procedure(cont, "helloworld", src)
sproc <- get_stored_procedure(cont, "helloworld")
exec_stored_procedure(sproc)
# more complex example: uploading data
sproc2 <- create_stored_procedure(cont, "myBulkUpload",
body=system.file("srcjs/bulkUpload.js", package="AzureCosmosR"))
list_stored_procedures(cont)
sw_male <- dplyr::filter(dplyr::starwars, sex == "male")
exec_stored_procedure(sproc2, parameters=list(sw_male))
delete_stored_procedure(sproc)
delete_stored_procedure(sproc2)
## End(Not run)