← All procedures

mongo.documents.count

Count documents matching a filter

MCPCLI
Package
@procedures/mongo · README
Path
["mongo","documents","count"]
CLI
mark mongo documents count
MCP tool
mongo.documents.count on the dev-tools server
As data
{"$proc":["mongo","documents","count"],"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","count"], {});
console.log(JSON.stringify(result));

From the command line

$ mark mongo documents count

As data, in a program

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

Input

FieldTypeRequiredDefaultDescription
collectionstringnoThe collection name. It takes the place of metadata.collection.
databasestringnoThe database name (default: the database of the connection)
queryobjectnoThe filter of the documents to count (default: all documents)

Output

FieldTypeRequiredDefaultDescription
countnumberyesThe number of documents that match
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
      },
      "query": {
        "description": "The filter of the documents to count (default: all documents)",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "count": {
        "type": "number",
        "description": "The number of documents that match"
      }
    },
    "required": [
      "count"
    ],
    "additionalProperties": {}
  }
}