Call

// Not available in this language yet.
Call( function, arguments, ... )
Call( function, arguments, ... )
Call( function, arguments, ... )
# Not available in this language yet.
Call( function, 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

String or Function Reference

The name, or reference, of the function to call. A function reference can be acquired using the Function function.

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:

// Not available in this language yet.
3
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "call": { "function": "increment" }, "arguments": 2 }'
HTTP/1.1 200 OK
{ "resource": 3 }
result, _ := client.Query(f.Call(f.Function("increment"), 2))

fmt.Println(result)
3
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());
3
client.query(q.Call(q.Function('increment'), 2))
.then((ret) => console.log(ret))
3
# Not available in this language yet.
3
// Not available in this language yet.
3

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!