← All procedures

mongo.collections.stats

Get collection statistics

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

From the command line

$ mark mongo collections stats

As data, in a program

{ "$proc": ["mongo", "collections", "stats"], "input": {} }

Input

FieldTypeRequiredDefaultDescription
collectionstringnoThe collection name. It takes the place of metadata.collection.
databasestringnoThe database name (default: the database of the connection)

Output

FieldTypeRequiredDefaultDescription
countnumberyesThe number of documents
sizenumberyesThe size of the documents, in bytes
avgObjSizenumberyesThe average size of a document, in bytes
storageSizenumberyesThe storage size, in bytes
nindexesnumberyesThe number of indexes
totalIndexSizenumberyesThe size of the indexes, in bytes
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
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "count": {
        "type": "number",
        "description": "The number of documents"
      },
      "size": {
        "type": "number",
        "description": "The size of the documents, in bytes"
      },
      "avgObjSize": {
        "type": "number",
        "description": "The average size of a document, in bytes"
      },
      "storageSize": {
        "type": "number",
        "description": "The storage size, in bytes"
      },
      "nindexes": {
        "type": "number",
        "description": "The number of indexes"
      },
      "totalIndexSize": {
        "type": "number",
        "description": "The size of the indexes, in bytes"
      }
    },
    "required": [
      "count",
      "size",
      "avgObjSize",
      "storageSize",
      "nindexes",
      "totalIndexSize"
    ],
    "additionalProperties": {}
  }
}