DEV Community

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

Posted on • Edited on

1 1 1 1 1

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.

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 👀

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay