* 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
)
| 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 |
nothing calls this directly
no test coverage detected