1×
Become a member
to unlock all features

Create egghead account to access 5000+ tutorials and resources from expert developers.

Create account
Autoplay

    Orchestrating multiple dependent expressions in the same transaction with Do

    faunadbFaunaDB

    There are a couple of different way to execute multiple expressions in FQL. Do is a function that lets us execute expressions in order and fail the entire query if one of the expressions fails.

    Do(
      Create(Collection("products")), {
        data: {
          "name": "Bacon",
          "description": "crispy, hot",
          "price": 4.27,
          "quantity": 1000,
          "warehouse": Ref(Collection("warehouses"), "244075679449088521"),
          "backorderLimit": 15,
          "backordered": false
        }
      }),
      Paginate(Match(Index("all_products")))
    )