Basic cookbook

This Fauna documentation cookbook takes you through hands-on tutorials that provide the foundational knowledge needed to develop any Fauna application. It is a prerequisite to the tutorials presented in the Advanced cookbook, which focuses on distinct technologies and use cases.

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!