MCPcopy
hub / github.com/mongodb/node-mongodb-native / createIndex

Method createIndex

src/collection.ts:636–651  ·  view source on GitHub ↗

* Creates an index on the db and collection collection. * * @param indexSpec - The field name or index specification to create an index for * @param options - Optional settings for the command * * @example * ```ts * const collection = client.db('foo').collection('bar'); *

(
    indexSpec: IndexSpecification,
    options?: CreateIndexesOptions
  )

Source from the content-addressed store, hash-verified

634 * ```
635 */
636 async createIndex(
637 indexSpec: IndexSpecification,
638 options?: CreateIndexesOptions
639 ): Promise<string> {
640 const indexes = await executeOperation(
641 this.client,
642 CreateIndexesOperation.fromIndexSpecification(
643 this,
644 this.collectionName,
645 indexSpec,
646 resolveOptions(this, options)
647 )
648 );
649
650 return indexes[0];
651 }
652
653 /**
654 * Creates multiple indexes in the collection, this method is only supported for

Callers

nothing calls this directly

Calls 3

executeOperationFunction · 0.90
resolveOptionsFunction · 0.90

Tested by

no test coverage detected