This page serves as a guide on how to use the delete() method in Memora. Before moving on, it’s a good idea to familiarize yourself with our main documents and collections pages.

Deleting a document

Here’s how you can use the delete() method to delete a document in Memora:

import Memora

memora = Memora.auth('your-api-key')

(
  memora
    .delete()
    .document('6b54347b-423d-4446-94cc-f182bd3a5a6f')
    .go()
)

In the above example, we permanently deleted the document with the 6b54347b-423d-4446-94cc-f182bd3a5a6f ID from the default collection.

Syntax

on('collection-name').delete().document(id)
delete().collection(name)

Parameters

id
string

The ID of the document you wish to delete.

name
string

The name of the collection you wish to delete.

Deleting a collection

Let’s delete a collection named citations:

(
  memora
    .delete()
    .collection('citations')
)

When you delete a collection, all documents inside it are also deleted.

Deleting a document inside a collection

Let’s delete inside a collection named citations:

(
  memora
    .in('citations')
    .delete()
    .document('de644368-df18-42bf-8c67-ed611573877c')
)

If you try deleting documents without specifying their collections, Memora will automatically try to delete the document ID inside the default collection named personal.

Was this page helpful?