delete()
Deletes your documents or collections
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 from 'usememora'
memora.auth('your-api-key')
await 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
in('collection-name').delete().document(id)
delete().collection(name)
Parameters
The ID of the document you wish to delete.
The name of the collection you wish to delete.
Deleting a collection
Let’s delete a collection named citations
:
await 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
:
await 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?