Var

Var( name )
Var( name )
Var( name )
Var (  name )
let name
let( name )
Var( name )
Var( name )

Description

The Var statement evaluates and returns the value stored in a named variable. The Var statement can only be used inside other statements, such as Let or Lambda.

Parameters

Argument Type Definition and Requirements

name

String

The name of the variable.

Returns

The value stored in the named variable.

Examples

The query below defines two variables in a Let statement. The first variable "x" contains the value 1 and the second variable "y" contains the value 2. When the simple "in" expression is executed, it returns the value stored in the variable "x".

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "let": { "x": 1, "y": 2 }, "in": { "var": "x" } }'
client.Query(Let(Obj("x", 1, "y", 2), Var("x")));
System.out.println(
         client.query(
               Let( "x", Value(1), "y", Value(2) ).in( Var("x") )
         ).get() );
result, _ := client.Query(f.Let(f.Obj{"x": 1, "y": 2}, f.Var("x")))

fmt.Println(result)
Let(Seq("x" -> 1, "y" -> 2), Var("x"))
client.query(q.let({"x": 1, "y": 2}, q.var("x")))
$client.query do
  let(x: 1, y: 2) do
    x
  end
end
client.query(Let(bindings: [ x: 1, y: 2 ], in: Var("x")))
client.query(
  q.Let({ x: 1, y: 2 }, q.Var('x'))
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": 1 }
1
1
1
1
1
1
1
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!