Call

// Not available in this language yet.
Call( function_ref, arguments, ... )
Call( function_ref, arguments, ... )
Call( function_ref, arguments, ... )
# Not available in this language yet.
# Not available in this language yet.
// Not available in this language yet.
Call( function_ref, arguments, ... )

Description

The Call function executes a user-defined function previously defined with the CreateFunction function. The Call function takes a variable length list of arguments which must match the type and number of the function being called. These arguments are provided to the function being executed by Call.

Parameters

Argument Type Definition and Requirements

function

Function Ref

A reference to the function. Given the name of the function, use the Function helper function to retrieve the function’s reference.

arguments

Expressions

The arguments for the function.

Returns

The evaluation of the function with the given arguments.

Examples

The following example executes a user-defined function with the associated arguments.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "call": { "function": "increment" }, "arguments": 2 }'
// Not available in this language yet.
Expr function_ref = client.query(
    Select(Arr(Value("ref")),
        CreateFunction(
            Obj( "name", Value("increment"),
            "body" , Query(Lambda(Value("x"), Add(Var("x"), Value(1))))
            )
        )
    )
 ).get();

 System.out.println(
         client.query( Call( Function("increment")  , Value(2))
         ).get());
result, _ := client.Query(f.Call(f.Function("increment"), 2))

fmt.Println(result)
// Not available in this language yet.
# Not available in this language yet.
# Not available in this language yet.
// Not available in this language yet.
client.query(q.Call(q.Function("increment"), 2))
  .then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": 3 }
3
3
3
3
3
3
3
3

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!