View all results

Bind Parameters

Bind parameters allow a query to receive values from the execution context instead of embedding those values directly in the query text.

A bind parameter is written as @name, where name is the parameter identifier.

Click on PARAMS to open the parameter editor and provide values for the parameters used in the query.
example.fql Ferret v2
query.fql
FQL
LET users = [ { name: "Ada", active: true }, { name: "Grace", active: false }, { name: "Linus", active: true } ] FOR user IN users FILTER user.active == @active RETURN user.name

In this example, @active is not a boolean literal written in the query. It is a parameter whose value is provided when the query is executed.

Parameter names

Parameter names must start with a letter or underscore. They may contain letters, digits, and underscores.

example.fql
read-only
RETURN @name RETURN @user_id RETURN @value1 RETURN @_value

The leading @ is part of the parameter syntax, but not part of the parameter name itself.

Passing parameter values

Parameter values are passed together with the query by the host application, runtime, or tool that executes the query.

They are not written as part of the query text.

A query fails if it references a bind parameter that was not provided.

example.fql Ferret v2
query.fql
FQL
RETURN @name

In this example, the query expects a parameter named name.

Parameters are values

Bind parameters represent values directly. They should not be wrapped in quotes.

example.fql Ferret v2
query.fql
FQL
LET users = [ { name: "Ada" }, { name: "Grace" }, { name: "Linus" } ] FOR user IN users FILTER user.name == @name RETURN user.name

Quoted text is always treated as a string literal. An unquoted @name expression refers to the parameter value.

Using parameters in expressions

Bind parameters can be used anywhere a value expression is expected.

example.fql Ferret v2
query.fql
FQL
RETURN CONCAT("prefix-", @id, "-suffix")

The parameter value participates in the expression the same way as any other value.

Dynamic property access

Bind parameters can also be used with bracket notation to access object properties dynamically.

example.fql Ferret v2
query.fql
FQL
LET doc = { foo: { bar: "baz" } } RETURN doc[@attr][@subattr]