get_udf {AzureCosmosR} | R Documentation |
Methods for working with Azure Cosmos DB user-defined functions
Description
Methods for working with Azure Cosmos DB user-defined functions
Usage
get_udf(object, ...)
## S3 method for class 'cosmos_container'
get_udf(object, funcname, ...)
list_udfs(object, ...)
create_udf(object, ...)
## S3 method for class 'cosmos_container'
create_udf(object, funcname, body, ...)
replace_udf(object, ...)
## S3 method for class 'cosmos_container'
replace_udf(object, funcname, body, ...)
## S3 method for class 'cosmos_udf'
replace_udf(object, body, ...)
delete_udf(object, ...)
## S3 method for class 'cosmos_container'
delete_udf(object, funcname, confirm = TRUE, ...)
## S3 method for class 'cosmos_udf'
delete_udf(object, ...)
Arguments
object |
A Cosmos DB container object, as obtained by |
... |
Optional arguments passed to lower-level functions. |
funcname |
The name of the user-defined function. |
body |
For |
confirm |
For |
Details
These are methods for working with user-defined functions (UDFs) in Azure Cosmos DB using the core (SQL) API. In the Cosmos DB model, UDFs are written in JavaScript and associated with a container.
Value
For get_udf
and create_udf
, an object of class cosmos_udf
. For list_udfs
, a list of such objects.
See Also
cosmos_container, get_stored_procedure
Examples
## Not run:
endp <- cosmos_endpoint("https://myaccount.documents.azure.com:443/", key="mykey")
db <- get_cosmos_database(endp, "mydatabase")
# importing the Star Wars data from dplyr
cont <- endp %>%
get_cosmos_database(endp, "mydatabase") %>%
create_cosmos_container(db, "mycontainer", partition_key="sex")
create_udf(cont, "times2", "function(x) { return 2*x; }")
list_udfs(cont)
# UDFs in queries are prefixed with the 'udf.' identifier
query_documents(cont, "select udf.times2(c.height) t2 from cont c")
delete_udf(cont, "times2")
## End(Not run)