FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, review the migration guide. Contact support@fauna.com with any questions.

Query

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Query( lambda )
query( lambda )
Query( lambda )
Query( lambda )
Query( lambda )

Description

The Query function wraps the provided Lambda function, preventing immediate execution, and making the function available for use in index bindings, CreateFunction, and ABAC predicates.

For example, when creating a named function with CreateFunction, Query defers execution of the Lambda function until the Call function is called.

While you can use a Query in a Let binding, it is not possible to call the bound function. You also cannot use a Query instead of a lambda function, such as with Map or Reduce.

Two functions are considered equal if their syntax is identical. For example:

Equals(Query(Lambda('a', 5)), Query(Lambda('a', 5)))
true

Parameters

Parameter Type Definition and Requirements

lambda

A Lambda function.

The Lambda function to wrap.

Returns

The wrapped query.

Examples

The following query returns the provided Lambda function wrapped in the Query wrapper:

client.query(
  q.Query(q.Lambda('X', q.Var('X')))
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
Query(Lambda("X", Var("X")))
result = client.query(
  q.query(q.lambda_("X", q.var("X")))
)
print(result)
Query({'api_version': '4', 'lambda': 'X', 'expr': {'var': 'X'}})
result, err := client.Query(
	f.Query(f.Lambda("X", f.Var("X"))))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
{[123 34 97 112 105 95 118 101 114 115 105 111 110 34 58 34 51 34 44 34 108 97 109 98 100 97 34 58 34 88 34 44 34 101 120 112 114 34 58 123 34 118 97 114 34 58 34 88 34 125 125]}
try
{
    Value result = await client.Query(
        Query(Lambda("X", Var("X")))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr])
Query(Lambda('X', Var('X')))
Query(Lambda("X", Var("X")))
Query metrics:
  •    bytesIn:  43

  •   bytesOut:  75

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 3ms

  •    retries:   0

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!