mongodb-delete-many

A “mongodb-delete-many” tool deletes all documents from a MongoDB collection that match a filter.

About

The mongodb-delete-many tool performs a bulk destructive operation, deleting ALL documents from a collection that match a specified filter.

The tool returns the total count of documents that were deleted. If the filter does not match any documents (i.e., the deleted count is 0), the tool will return an error.

This tool is compatible with the following source type:


Example

Here is an example that performs a cleanup task by deleting all products from the inventory collection that belong to a discontinued brand.

kind: tools
name: retire_brand_products
type: mongodb-delete-many
source: my-mongo-source
description: Deletes all products from a specified discontinued brand.
database: ecommerce
collection: inventory
filterPayload: |
    { "brand_name": {{json .brand_to_delete}} }
filterParams:
  - name: brand_to_delete
    type: string
    description: The name of the discontinued brand whose products should be deleted.

Reference

fieldtyperequireddescription
typestringtrueMust be mongodb-delete-many.
sourcestringtrueThe name of the mongodb source to use.
descriptionstringtrueA description of the tool that is passed to the LLM.
databasestringtrueThe name of the MongoDB database containing the collection.
collectionstringtrueThe name of the MongoDB collection from which to delete documents.
filterPayloadstringtrueThe MongoDB query filter document to select the documents for deletion. Uses {{json .param_name}} for templating.
filterParamslistfalseA list of parameter objects that define the variables used in the filterPayload.