Cookbook

The cookbook section of the Fauna documentation includes task-oriented information organized by functional area to quickly gain an understanding of how to develop applications with Fauna.

Follow these how-tos for a learning experience that walks you through practical, hands-on exercises covering key Fauna concepts and techniques. Cookbooks are organized as a graduated set of recipes, progressing from the most common or basic operations, to more advanced tasks. You can start in the cookbook with the tutorial that matches your experience level.

The associated reference documentation for these cookbooks is found in the Reference section.

What you’ll find here

FQL language and API

This cookbook takes you through hands-on tutorials that provide the foundational Fauna Query Language (FQL) language knowledge needed to develop a Fauna application.

FSL

This cookbook introduces you to the Fauna Schema Language (FSL). Using configuration and schema files to define your projects and database schema, you can easily make updates to your environment and schema and reliably share those updates.

Access control

This cookbook shows you how to set up and manage access control to authentication with a Fauna database and get authorization to act on database resources.

How to use the cookbook

This cookbook provides a progressive, hands-on experience that facilitates learning Fauna, FQL, and FSL. Each tutorial builds on what you learned in previous tutorials.

After setting up your environment and verifying that you can successfully make queries, progress through the tutorials sequentially, or jump to the topic you’re currently interested in or that matches your experience level with Fauna.

When trying the examples in the Shell, make sure the TYPECHECK button in the upper-right is enabled with the check mark displayed. Type checking should be enabled when trying examples.

The examples assume a given database setup, so fields with values set at creation time, such as id and ts, might differ in the documentation from the values you see. Where applicable, replace the values in the examples with your actual values.

The FQL language reference and FQL API reference sections are references for finding more detailed information about the operations and interfaces used in the cookbook examples.

Environment setup for running the examples

The easiest way to try the examples as you follow the tutorials is to use the Dashboard. If you’ve already tried the Dashboard quick start, you’re already set up to run the examples.

Because the FQL syntax is the same in all contexts, you can also run the same examples programmatically using one of the Supported drivers for your language of choice.

Notes on error handling

As you progress through the cookbook tutorials and try the examples locally, you might encounter error responses from Fauna. Errors can be caused by typos or other environment issues, but the error messages can help with debugging the error so you can continue with the exercises.

For example, when type checking is enabled, an error is raised by the following example because the non-null assertion postfix operator is omitted:

CoffeeBean.byId("366190711733747780").update(
  { Owner: "Healthy Grounds" }
)
QueryCheckError

error: Type `CoffeeBean | NullCoffeeBean` isn't a subtype of `{ update: { Owner: "Healthy Grounds" } => Any, ... }`
at *query*:1:39
  |
1 | CoffeeBean.byId("366190711733747780").update(
  |                                       ^^^^^^
  |
cause: Type `Null` doesn't have field `update`: use the ! operator to remove the null case
  |
1 | CoffeeBean.byId("366190711733747780").update(
  | ^^^^^^^^^^^^^^^
  |

 

Notice that the error message indicates the location of the error, which should help in finding the cause.

If you’re unable to find the cause of the error or find that the documentation provides insufficient guidance, email docs@fauna.com with a description of the error.

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!