← All procedures
mongo.indexes.create
Create an index on a collection
MCPCLI- Package
- @procedures/mongo · README
- Path
["mongo","indexes","create"]- CLI
mark mongo indexes create --keys <object>- MCP tool
mongo.indexes.create on the dev-tools server- As data
{"$proc":["mongo","indexes","create"],"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","indexes","create"], { keys: {} });
console.log(JSON.stringify(result));From the command line
$ mark mongo indexes create --keys <object>
As data, in a program
{ "$proc": ["mongo", "indexes", "create"], "input": { "keys": {} } }Input
| Field | Type | Required | Default | Description |
|---|
collection | string | no | | The collection name. It takes the place of metadata.collection. |
database | string | no | | The database name (default: the database of the connection) |
keys | object | yes | | The fields of the index and their order: 1, -1, "text" or "2dsphere" |
options | object | no | | The options of the index |
Output
| Field | Type | Required | Default | Description |
|---|
acknowledged | boolean | yes | | True when the server confirmed the write |
indexName | string | yes | | The name of the new index |
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
},
"keys": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"anyOf": [
{
"type": "number",
"const": 1
},
{
"type": "number",
"const": -1
},
{
"type": "string",
"const": "text"
},
{
"type": "string",
"const": "2dsphere"
}
]
},
"description": "The fields of the index and their order: 1, -1, \"text\" or \"2dsphere\""
},
"options": {
"description": "The options of the index",
"type": "object",
"properties": {
"name": {
"description": "The name of the index",
"type": "string"
},
"unique": {
"description": "A unique index",
"type": "boolean"
},
"sparse": {
"description": "A sparse index",
"type": "boolean"
}
},
"additionalProperties": {}
}
},
"required": [
"keys"
]
},
"output": {
"type": "object",
"properties": {
"acknowledged": {
"type": "boolean",
"description": "True when the server confirmed the write"
},
"indexName": {
"type": "string",
"description": "The name of the new index"
}
},
"required": [
"acknowledged",
"indexName"
],
"additionalProperties": {}
}
}