Function
Function( name, [database] )
Function( name, [database] )
Function( name, [database] )
Function( name, [database] )
function( name, [database] )
Function( name, [database] )
Description
The Function
function returns a Reference for
the specified function name
in the specified child database
. If a
child database
is not specified, the returned function reference
belongs to the current database.
Returns
A reference to a function with the specified name
, in the specified
child database
(or the current database if database
is not
specified).
Examples
The following query gets a reference to the function named increment
:
Value result = await client.Query(
Function("increment")
);
RefV(id = "increment", collection = RefV(id = "functions"))
result, err := client.Query(
f.Function("increment"))
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
fmt.Println(result)
}
{increment 0xc00014c090 0xc00014c090 <nil>}
System.out.println(
client.query(
Function("increment")
).get());
ref(id = "increment", collection = ref(id = "functions"))
client.query(
q.Function('increment')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
Function("increment")
result = client.query(
q.function("increment")
)
print(result)
Ref(id=increment, collection=Ref(id=functions))
println(Await.result(
client.query(
Function("increment")
),
5.seconds
))
ref(id = "increment", collection = ref(id = "functions"))
The following query demonstrates how to retrieve the function document by its reference:
Value result = await client.Query(
Get(Function("increment"))
);
ObjectV(ref: RefV(id = "increment", collection = RefV(id = "functions")),ts: LongV(1603756293670000),name: StringV(increment),body: QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr]))
result, err := client.Query(
f.Get(f.Function("increment")))
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
fmt.Println(result)
}
map[body:{[123 34 97 112 105 95 118 101 114 115 105 111 110 34 58 34 50 46 49 50 34 44 34 108 97 109 98 100 97 34 58 34 88 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 88 34 125 44 49 93 125 125]} name:increment ref:{increment 0xc00008e240 0xc00008e240 <nil>} ts:1603747162820000]
System.out.println(
client.query(
Get(Function("increment"))
).get());
{ref: ref(id = "increment", collection = ref(id = "functions")), ts: 1581379483580000, name: "increment", body: QueryV({lambda=X, expr={add=[{var=X}, 1]}})}
client.query(
q.Get(q.Function('increment'))
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
{ ref: Function("increment"),
ts: 1581379483580000,
name: 'increment',
body: Query(Lambda("X", Add(Var("X"), 1))) }
result = client.query(
q.get(q.function("increment"))
)
print(result)
{'ref': Ref(id=increment, collection=Ref(id=functions)), 'ts': 1603752408980000, 'name': 'increment', 'body': Query({'api_version': '2.12', 'lambda': 'X', 'expr': {'add': [{'var': 'X'}, 1]}})}
println(Await.result(
client.query(
Get(Function("increment"))
),
5.seconds
))
{ref: ref(id = "increment", collection = ref(id = "functions")), ts: 1594678055360000, name: "increment", body: {api_version: "2.12", lambda: "X", expr: {add: [{var: "X"}, 1]}}}
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!