Delete an key.


delete(): { id: ID, coll: Collection}


The delete() method deletes the key from storage, and returns an Object representing the deleted key with the id and coll identity fields.



Return value

Type Description


Document doesn’t exist or is inaccessible. See NullDoc.


Basic example

Key.byId("371460335192768546") /* deleted */

Delete all keys

To avoid throttling, you can incrementally delete all keys 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 `Key` system collection documents.
// Uses `pageSize()` to limit the page size.
// Uses `paginate()` to project the after cursor.
let page = Key.all().pageSize(200).paginate()

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

// Use `forEach()` to delete each `Key` 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!