Orchestrating multiple dependent expressions in the same transaction with Do

InstructorChris Biscardi

Share this video with your friends

Send Tweet

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")))
)