Delete

CapyDB provides a straightforward way to delete documents from a collection using operations similar to MongoDB's delete functionality. You can delete one or multiple documents that match a specified filter.

Delete Operation

The delete operation allows you to remove documents from a collection that match a specified filter. This operation is permanent and cannot be undone.

Example Python Code for delete

Here's how you can delete documents using Python:

# Filter to match the document(s) to delete
filter_criteria = {
    "name": "Alice Smith"
}

# Sending the request
response = collection.delete(filter_criteria)

Delete Response

A successful delete operation will return a JSON response containing information about the number of documents deleted. Here's an example response:

{
  "deleted_count": 1
}

Parameters for Delete Operations

ParameterDescription
filterA query object to match the documents to delete. This works the same way as MongoDB filters, allowing you to specify conditions to find the documents. For more details, refer to the filter operator syntax.

How can we improve this documentation?

Got question? Email us