← All procedures

mongo.documents.insert

Insert one or more documents

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

From the command line

$ mark mongo documents insert --documents <object | object[]>

As data, in a program

{
  "$proc": ["mongo", "documents", "insert"],
  "input": { "documents": "<documents>" }
}

Input

FieldTypeRequiredDefaultDescription
collectionstringnoThe collection name. It takes the place of metadata.collection.
databasestringnoThe database name (default: the database of the connection)
documentsobject | object[]yesOne document, or a list of documents

Output

FieldTypeRequiredDefaultDescription
acknowledgedbooleanyesTrue when the server confirmed the write
insertedIdsstring[]yesThe ids of the new documents, as text
insertedCountnumberyesThe number of new 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
      },
      "documents": {
        "anyOf": [
          {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          {
            "type": "array",
            "items": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            }
          }
        ],
        "description": "One document, or a list of documents"
      }
    },
    "required": [
      "documents"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "acknowledged": {
        "type": "boolean",
        "description": "True when the server confirmed the write"
      },
      "insertedIds": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "The ids of the new documents, as text"
      },
      "insertedCount": {
        "type": "number",
        "description": "The number of new documents"
      }
    },
    "required": [
      "acknowledged",
      "insertedIds",
      "insertedCount"
    ],
    "additionalProperties": {}
  }
}