eval
Description
The eval
command runs the query that you specify. If you specify
DBNAME, the query is executed in the specified child database. The
query can be read from STDIN, a file, or the command line. The query
results can be output to STDOUT or a file, and you can specify the
output format.
If you don’t pass any options at the command line, Fauna uses the
options specified in the
fauna-shell
configuration
file.
If the query does not execute successfully and returns an error,
fauna-shell
exits with a non-zero exit code.
It is not possible to use this command to execute a query in a parent or peer database. To access a database outside of the current database, use the Fauna Dashboard. |
Arguments
Argument | Description |
---|---|
DBNAME |
Optional - The name of a child database where the query should be executed. |
QUERY |
Optional - The query that you want to execute. |
Options
Option | Description |
---|---|
|
Optional - The Fauna server domain, that is, the hostname where
Fauna is running. Defaults to |
|
Optional - The name of the endpoint to use for the command. |
|
Optional - The connection port. Defaults to 8443. |
|
Optional - The connection scheme. Must be one of |
|
Optional - The secret to use. A secret authenticates your connection to Fauna, and connects you to a specific database. |
|
Optional - The connection timeout, an integer number of milliseconds.
When the specified period has elapsed, The default is zero, which means that |
|
Optional - The file to read the query (or queries) from. |
|
Optional - The output format. Must be one of:
The default is |
Examples
-
The following invocation shows running a query passed as an argument:
fauna eval "Paginate(Collections())" {"data":[{"@ref":{"id":"FirstCollection","collection":{"@ref":{"id":"collections"}}}}]}
-
The following invocation shows running a query that exists in a file. The query in the file is identical to the previous example:
fauna eval --file=./query.fql {"data":[{"@ref":{"id":"FirstCollection","collection":{"@ref":{"id":"collections"}}}}]}
-
The following invocation shows passing a query via STDIN:
echo "Paginate(Collections())" | fauna eval --stdin {"data":[{"@ref":{"id":"FirstCollection","collection":{"@ref":{"id":"collections"}}}}]
-
The following invocation shows a child database name and a query argument:
fauna eval prydain "Paginate(Collections())" {"data":[]}
-
The following invocation shows what happens when the specified child database does not exist:
fauna eval ystrad "Paginate(Collections())" › Error: Database 'ystrad' doesn't exist
-
The following invocation shows sending query output to a file:
fauna eval "Paginate(Collections())" --output=./output.json
cat ./output.json {"data":[{"@ref":{"id":"FirstCollection","collection":{"@ref":{"id":"collections"}}}}]
-
The following invocation shows sending query output to a file in Fauna Shell format:
fauna eval "Paginate(Collections())" --format=shell --output=./output.json
cat ./output.json { data: [ Collection("FirstCollection") ] }
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!