fauna project init
Initialize a project directory by creating a
.fauna-project file.
Description
fauna project init initializes a project directory by creating a
.fauna-project file.
fauna project init
Interactive prompts
The fauna project init command requires input to interactive prompts.
When running fauna project init, you’ll be prompted for:
-
Schema directory
-
Location to store your
.fslschema files -
Default: Current director
-
Example:
schemaordb/schema
-
-
Default environment
-
Default environment for the project
-
Example:
dev,qa, orprod -
Defined in
.fauna-project
-
-
Default endpoint
-
Default Fauna endpoint for the environment
-
Example:
fauna-usorfauna-eu -
Defined in
.fauna-shell
-
-
Default database
-
Default database for the environment
-
Example:
myapp/devormyproject_development
-
Project directory
A project directory includes:
<APP>/ // Directory containing app source code (optional)
├── .fauna-project // INI-format file containing Fauna CLI defaults for the project
├── schema/ // Directory containing Fauna .fsl schema files
│ └── *.fsl
...
-
A
.fauna-projectfile that stores a default configuration for the project in Fauna CLI -
.fslfiles for the project’s database(s), typically stored in a subdirectory -
(Optional) The application’s source code
For more about the .fauna-project file, see
Project configuration.
.fauna-project file
.fauna-project is an INI-format file
that stores a default Fauna CLI configuration for a project directory.
The Fauna CLI uses these defaults when you run commands in the directory. If
you run commands in a subdirectory, the CLI searches parent directories for the
nearest .fauna-project file.
Example:
schema_directory=schema
default=dev
[environment.dev]
endpoint=fauna-us
database=accounts/dev
[environment.qa]
endpoint=fauna-us
database=accounts/qa
[environment.prod]
endpoint=fauna-us
database=accounts/prod
Several Fauna CLI commands, such as fauna eval,
let you easily switch environments using the --environment option:
fauna eval "Product.all()" --environment='prod'
For more information about environments, see environments.
|
The |
Set up a project
You can use fauna project init to set up a project directory and FSL files for
an application. See Set up a project using FSL and the Fauna CLI.
Arguments
| Argument | Description |
|---|---|
|
The directory to initialize as a Fauna project. Defaults to the current directory. If the directory doesn’t exist, the command creates it. |
Examples
Basic example
fauna project init
When prompted, provide:
-
A schema directory used to store
.fslfiles. If the directory doesn’t exist, the command creates it. Press Enter to use the current directory. -
A default environment name. See environments.
-
A default endpoint to use for Fauna CLI commands.
-
A default database for Fauna CLI commands.
Specify a project directory
To specify a project directory to create the
.fauna-project file in:
fauna project init path/to/some/other/dir