cosmos_udf: Methods for working with Azure Cosmos DB user-defined...

Description Usage Arguments Details Value See Also Examples

Description

Methods for working with Azure Cosmos DB user-defined functions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 get_cosmos_container or create_cosmos_container, or for delete_udf.cosmos_udf, the function object.

...

Optional arguments passed to lower-level functions.

funcname

The name of the user-defined function.

body

For create_udf and replace_udf, the body of the function. This can be either a character string containing the source code, or the name of a source file.

confirm

For delete_udf, whether to ask for confirmation before deleting.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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)

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