CreateFunction
CreateFunction( param_object )
CreateFunction( param_object )
CreateFunction( param_object )
CreateFunction( param_object )
create_function( param_object )
CreateFunction( param_object )
Description
The CreateFunction
operation adds a new user-defined function with the
specified parameters.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Object |
The |
param_object
Field Name | Field Type | Definition and Requirements | ||
---|---|---|---|---|
|
The name of the function. Cannot be |
|||
|
The Fauna Query Language instructions to be executed. |
|||
|
Optional - This is user-defined metadata for the user-defined function. It is provided for the developer to store information at the function level. |
|||
|
Optional - Specifies the role that should be used when the user-defined function is called, which would typically be used to provide privilege escalation when current privileges would otherwise be too restrictive. To use a built-in role, specify one of the strings
|
Returns
An object containing the metadata of CreateFunction
operations.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
The reference is an automatically-generated, unique identifier within the database to identify the function that was created. |
|
|
The logical name of the function created. |
|
|
The role that should be used when the function is called. Only included
when |
|
|
The timestamp, with microsecond resolution, associated with the creation of the function. |
|
|
The Fauna Query Language instructions to be executed. |
Examples
The following query creates a user-defined function called "double":
ObjectV(ref: RefV(id = "double", collection = RefV(id = "functions")),ts: LongV(1611102338170000),name: StringV(double),body: QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr]))
map[body:{[123 34 97 112 105 95 118 101 114 115 105 111 110 34 58 34 52 34 44 34 108 97 109 98 100 97 34 58 34 120 34 44 34 101 120 112 114 34 58 123 34 97 100 100 34 58 91 123 34 118 97 114 34 58 34 120 34 125 44 123 34 118 97 114 34 58 34 120 34 125 93 125 125]} name:double ref:{double 0xc000178270 0xc000178270 <nil>} ts:1631915951360000]
{ref: ref(id = "double", collection = ref(id = "functions")), ts: 1608767567800000, name: "double", body: QueryV({api_version=4, lambda=x, expr={add=[{var=x}, {var=x}]}})}
{
ref: Function("double"),
ts: 1591997162610000,
name: 'double',
body: Query(Lambda("x", Add(Var("x"), Var("x"))))
}
{'ref': Ref(id=double, collection=Ref(id=functions)), 'ts': 1611102297910000, 'name': 'double', 'body': Query({'api_version': '4', 'lambda': 'x', 'expr': {'add': [{'var': 'x'}, {'var': 'x'}]}})}
{
ref: Function("double"),
ts: 1631916677410000,
name: 'double',
body: Query(Lambda("x", Add(Var("x"), Var("x"))))
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!