Drop Collection

CapyDB provides a method to completely remove a collection including all of its documents, indexes, and metadata. This operation is permanent and cannot be undone.

Drop Operation

The drop operation deletes the entire collection. Use this with caution as it will permanently remove all data in the collection.

Example Python Code for drop

Here's how you can drop a collection using Python:

from capydb import CapyDB
from dotenv import load_dotenv

load_dotenv()
capydb = CapyDB()
db = capydb.db("your_db_name")
collection = db.collection("your_collection_name")

# Drop the entire collection
collection.drop()

Example TypeScript Code for drop

Here's how you can drop a collection using TypeScript:

Response

The drop method doesn't return any meaningful content on success (HTTP 204 No Content response). If there is an error, appropriate exceptions will be thrown.

Important Considerations

  • The drop operation is permanent and cannot be undone
  • All documents and indexes in the collection will be deleted
  • Consider creating backups before dropping collections in a production environment