Delete an database.


delete(): NullDatabaseDef


The delete() method deletes a database.

Delete a top-level database

To use delete() to delete a top-level database, you must use a secret scoped to the account’s top-level context. You can create this secret using the cloud-login command.

You can also delete a top-level database using the Fauna Dashboard UI or the Fauna CLI's delete-database command.

You can’t use the Dashboard Shell to run an FQL query that uses delete() to delete a top-level database.


When you delete a database, its data becomes inaccessible and is asynchronously deleted. As part of the deletion process, Fauna recursively deletes:

  • Any keys scoped to the database.

  • The database’s child databases, including any nested databases.

Deleting a database with a large number of keys can exceed Transactional Write Ops throughput limits and cause errors with a 429 (Capacity limit) HTTP status code.

Deleting a database with a large number of child databases can cause errors with a 440 (Client timeout) HTTP status code.

To avoid throttling or timeouts, incrementally delete all keys and child databases before deleting the database. See delete all keys and delete all child databases.



Return value

Type Description


Database doesn’t exist or is inaccessible.


Basic example

Database.byName("childDB") /* deleted */

Delete all child databases

To avoid timeouts, you can incrementally delete all child databases for a database before deleting the database itself.

To stay within transaction size limits, use paginate() to perform the deletions over several transactions instead of one.

// Gets all `Database` system collection documents.
// Uses `pageSize()` to limit the page size.
// Uses `paginate()` to project the after cursor.
let page = Database.all().pageSize(200).paginate()

// `paginate()` returns an object. The object's `data` property
// contains an array of `Database` documents.
let data =

// Use `forEach()` to delete each `Database` document in the
// `data` array.
data.forEach(doc => doc.delete()

// Project the `after` cursor returned by `paginate()`.
// Use the cursor to iterate through the remaining pages.
page {
  after: "hdWDxoq..."

Subsequent transactions use the cursor and Set.paginate() to iterate through the remaining pages:

// Uses `Set.paginate()` to iterate through pages.
let page = Set.paginate("hdWDxoq...")

let data =

data.forEach(doc => doc.delete()

page {

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email

Thank you for your feedback!