Function
Function( name, [database] )
Function( name, [database] )
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
:
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{ "function": "increment" }'
Value result = await client.Query(
Function("increment")
);
IResult<Value> data = result.To<Value>();
data.Match(
Success: value => Console.WriteLine($"{value}"),
Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
System.out.println(
client.query(
Function("increment")
).get());
result, err := client.Query(
f.Function("increment"))
if (err != nil) {
fmt.Println(err)
} else {
fmt.Println(result)
}
println(Await.result(
client.query(
Function("increment")
),
5.seconds
))
print(client.query(
q.function("increment")
))
$client.query do
function 'increment'
end
client.query(Function("increment"))
client.query(
q.Function("increment")
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": { "@ref": "functions/increment" } }
RefV(id = "increment", collection = RefV(id = "functions"))
ref(id = "increment", collection = ref(id = "functions"))
{increment 0xc000436090 0xc000436090 <nil>}
ref(id = "increment", collection = ref(id = "functions"))
Ref(id=increment, collection=Ref(id=functions))
{ "@ref": "functions/increment" }
{ "@ref": "functions/increment" }
Function("increment")
The following query demonstrates how to retrieve the function document by its reference:
Value result = await client.Query(
Get(Function("increment"))
);
IResult<Value> data = result.To<Value>();
data.Match(
Success: value => Console.WriteLine($"{value}"),
Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
result, err := client.Query(
f.Get(f.Function("increment")))
if (err != nil) {
fmt.Println(err)
} else {
fmt.Println(result)
}
System.out.println(
client.query(
Get(Function("increment"))
).get());
client.query(
q.Get(q.Function("increment"))
)
.then((ret) => console.log(ret))
print(client.query(
q.get(q.function("increment"))
))
println(Await.result(
client.query(
Get(Function("increment"))
),
5.seconds
))
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
ObjectV(ref: RefV(id = "increment", collection = RefV(id = "functions")),ts: LongV(1581379483580000),name: StringV(increment),body: QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr]))
map[body:{[123 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 0xc00016ed80 0xc00016ed80 <nil>} ts:1581379483580000]
{ref: ref(id = "increment", collection = ref(id = "functions")), ts: 1581379483580000, name: "increment", body: QueryV({lambda=X, expr={add=[{var=X}, 1]}})}
{ ref: Function("increment"),
ts: 1581379483580000,
name: 'increment',
body: Query(Lambda("X", Add(Var("X"), 1))) }
{'ref': Ref(id=increment, collection=Ref(id=functions)), 'ts': 1581379483580000, 'name': 'increment', 'body': Query({'lambda': 'X', 'expr': {'add': [{'var': 'X'}, 1]}})}
{ref: ref(id = "increment", collection = ref(id = "functions")), ts: 1581379483580000, name: "increment", body: {lambda: "X", expr: {add: [{var: "X"}, 1]}}}
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!