← All procedures

mongo.documents.delete

Delete documents matching a filter

MCPCLI
Package
@procedures/mongo · README
Path
["mongo","documents","delete"]
CLI
mark mongo documents delete
MCP tool
mongo.documents.delete on the dev-tools server
As data
{"$proc":["mongo","documents","delete"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/mongo"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["mongo","documents","delete"], {});
console.log(JSON.stringify(result));

From the command line

$ mark mongo documents delete

As data, in a program

{ "$proc": ["mongo", "documents", "delete"], "input": {} }

Input

FieldTypeRequiredDefaultDescription
collectionstringnoThe collection name. It takes the place of metadata.collection.
databasestringnoThe database name (default: the database of the connection)
filterobjectnoThe filter of the documents (give exactly one of id or filter). An empty filter needs confirm: true.
idstringnoThe id of one document (the alternative to filter)
idType"auto" | "objectId" | "string"noHow to read the id: "auto" (the default: an ObjectId or a string), "objectId" or "string"
multibooleannoChange every matching document, not only the first one
confirmbooleannoSet to true to use an empty filter, which matches every document

Output

FieldTypeRequiredDefaultDescription
acknowledgedbooleanyesTrue when the server confirmed the write
deletedCountnumberyesThe number of deleted documents
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "collection": {
        "description": "The collection name. It takes the place of metadata.collection.",
        "type": "string",
        "minLength": 1
      },
      "database": {
        "description": "The database name (default: the database of the connection)",
        "type": "string",
        "minLength": 1
      },
      "filter": {
        "description": "The filter of the documents (give exactly one of id or filter). An empty filter needs confirm: true.",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      },
      "id": {
        "description": "The id of one document (the alternative to filter)",
        "type": "string",
        "minLength": 1
      },
      "idType": {
        "description": "How to read the id: \"auto\" (the default: an ObjectId or a string), \"objectId\" or \"string\"",
        "type": "string",
        "enum": [
          "auto",
          "objectId",
          "string"
        ]
      },
      "multi": {
        "description": "Change every matching document, not only the first one",
        "type": "boolean"
      },
      "confirm": {
        "description": "Set to true to use an empty filter, which matches every document",
        "type": "boolean"
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "acknowledged": {
        "type": "boolean",
        "description": "True when the server confirmed the write"
      },
      "deletedCount": {
        "type": "number",
        "description": "The number of deleted documents"
      }
    },
    "required": [
      "acknowledged",
      "deletedCount"
    ],
    "additionalProperties": {}
  }
}