Prerequisites
- TerminusDB running locally (install guide)
- A connected client instance with documents to delete
What you'll achieve By the end of this guide, you will have deleted documents from your TerminusDB database using the JavaScript client, the Python client, or the HTTP API.
To delete a document you need its document ID (e.g. Player/George).
Delete a document
Example: TypeScript
const deleteDoc = async () => {
const docId = "Player/George"
await client.deleteDocument({ id: docId })
console.log(`Deleted ${docId}`)
}Example: Python
doc_id = "Player/George"
client.delete_document(doc_id)curl -u admin:root -X DELETE \
"http://localhost:6363/api/document/admin/mydb/local/branch/main?author=admin&message=Delete+document" \
-H "Content-Type: application/json" \
-d '["Player/George"]'Deleting a document is permanent within the current branch. If you need to recover a deleted document, use time travel to access a previous commit.
Next steps
You've learnt the full CRUD lifecycle. To go further:
- Time travel — recover deleted documents by accessing previous commits
- Branch and merge — test destructive changes safely on a branch
- Query with WOQL — find documents using pattern-matching queries