DEV Community

Cover image for Simple deletes in Fauna Query Language - (FQL)
Kirk Kirkconnell
Kirk Kirkconnell

Posted on • Updated on

Simple deletes in Fauna Query Language - (FQL)

Now that you have written some data and updated some data in Fauna, in this how to let's delete some data!

In my last post, you saw getting a result set from the byStatus index and using the .forEach() or .map() functions to iterate through the results, deletes are easy.

Deleting data from a Collection in Fauna

To delete, we just call the .delete() function inside .forEach(), and as it iterates through the documents, it deletes each one of them. Here are two different styles of using forEach to do this. You can choose for deletes or other operations which style you want to use.

Order.byStatus("shipped", "20220").forEach(.delete())
Order.byStatus("shipped", "20220").forEach(x => x.delete())
Enter fullscreen mode Exit fullscreen mode

This can be done in two different ways, but they are essentially the same. It is a style call.

One side note, I am using the .forEach() function as I am deleting documents thus not returning anything. Since the .delete() function returns nothing, and .forEach() returns no data, this is more efficient.


Fauna is a serverless, globally distributed strong consistent database designed for modern application development. It offers the flexibility of NoSQL with the safety and ease of traditional relational databases. It provides seamless scalability, strong consistency, and multi-model access capabilities, making it an ideal choice for developers seeking to build fast, reliable applications without the operational overhead of traditional database management. Fauna's support for ACID transactions, and its temporal database features further enhance its utility, allowing for efficient data retrieval, updates, and historical data analysis.

Top comments (0)