shell

Start an interactive Fauna session to run queries.

Syntax

fauna shell [DB_PATH] [--url <value>] [--timeout <value>] [--secret <value>] [--endpoint <value>] [--environment <value>] [--file <value> ] [--stdin] [--output <value>] [--format json|json-tagged|shell] [--version 4|10] [--typecheck]

Description

The shell command starts an interactive query shell for sending Fauna database queries.

By default, this command supports FQL v10 queries. For FQL v4 queries, use the --version 4 option.

You can’t use this command to run queries against a parent or peer database.

Arguments

Argument Description

DB_PATH

Database path.

Options

Option Description

--endpoint

Connection endpoint from ~/.fauna-shell.

--environment

Environment to use, from a Fauna project.

--file

Name of file with queries to run.

--format

Output format:
     json
     json-tagged
     shell

--help

Help for run-queries command.

--output

File to write output to.

--secret

Secret key. Overrides the secret in ~/.fauna-shell.

--stdin

Read file input from stdin. Write to stdout by default.

--timeout

Connection timeout (milliseconds).

--typecheck

Enable typechecking.

--url

Database URL. Overrides the URL in ~/.fauna-shell.

--version

FQL Version:
     4 = FQL version 4
     10 = (default) FQL version 10

Example

Start the shell:

fauna shell

At the prompt, run a query to list all of the database collections using the FQL Collection.all() method:

Collection.all()
{
  data: [
    {
      name: "Product",
      coll: Collection,
      ts: Time("2099-06-21T18:39:00.480Z"),
      constraints: [
        {
          unique: [
            {
              field: ".name",
              mva: false
            },
            {
              field: ".description",
              mva: false
            },
            {
              field: ".store",
              mva: false
            }
          ],
          status: "active"
        }
      ],
      history_days: 0,
      indexes: {
        byName: {
          terms: [
            {
              field: ".name",
              mva: false
            }
          ],
          values: [
            {
              field: ".quantity",
              order: "desc",
              mva: false
            }
          ],
          queryable: true,
          status: "complete"
        },
        byStore: {
          terms: [
            {
              field: ".store",
              mva: false
            }
          ],
          values: [
            {
              field: ".name",
              order: "asc",
              mva: false
            },
            {
              field: ".description",
              order: "asc",
              mva: false
            },
            {
              field: ".price",
              order: "asc",
              mva: false
            }
          ],
          queryable: true,
          status: "complete"
        },
        sortedByPriceHighToLow: {
          values: [
            {
              field: ".price",
              order: "desc",
              mva: false
            },
            {
              field: ".name",
              order: "asc",
              mva: false
            },
            {
              field: ".description",
              order: "asc",
              mva: false
            }
          ],
          queryable: true,
          status: "complete"
        },
        sortedByPriceLowToHigh: {
          values: [
            {
              field: ".price",
              order: "asc",
              mva: false
            },
            {
              field: ".name",
              order: "asc",
              mva: false
            },
            {
              field: ".description",
              order: "asc",
              mva: false
            }
          ],
          queryable: true,
          status: "complete"
        }
      }
    },
    ...
  ]
}

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!