mongodb 6.5.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +9 -9
  2. package/lib/admin.js +9 -9
  3. package/lib/admin.js.map +1 -1
  4. package/lib/bson.js +33 -22
  5. package/lib/bson.js.map +1 -1
  6. package/lib/bulk/common.js +13 -12
  7. package/lib/bulk/common.js.map +1 -1
  8. package/lib/change_stream.js +28 -18
  9. package/lib/change_stream.js.map +1 -1
  10. package/lib/client-side-encryption/auto_encrypter.js +2 -2
  11. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  12. package/lib/client-side-encryption/client_encryption.js +6 -6
  13. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  14. package/lib/client-side-encryption/providers/aws.js +13 -10
  15. package/lib/client-side-encryption/providers/aws.js.map +1 -1
  16. package/lib/client-side-encryption/providers/azure.js +6 -3
  17. package/lib/client-side-encryption/providers/azure.js.map +1 -1
  18. package/lib/cmap/auth/aws_temporary_credentials.js +140 -0
  19. package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
  20. package/lib/cmap/auth/gssapi.js +7 -6
  21. package/lib/cmap/auth/gssapi.js.map +1 -1
  22. package/lib/cmap/auth/mongodb_aws.js +8 -101
  23. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  24. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +1 -1
  25. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -1
  26. package/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js +2 -1
  27. package/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js.map +1 -1
  28. package/lib/cmap/auth/mongodb_oidc/service_workflow.js +1 -1
  29. package/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -1
  30. package/lib/cmap/auth/scram.js +2 -2
  31. package/lib/cmap/auth/scram.js.map +1 -1
  32. package/lib/cmap/commands.js +24 -111
  33. package/lib/cmap/commands.js.map +1 -1
  34. package/lib/cmap/connect.js +4 -4
  35. package/lib/cmap/connect.js.map +1 -1
  36. package/lib/cmap/connection.js +61 -36
  37. package/lib/cmap/connection.js.map +1 -1
  38. package/lib/cmap/connection_pool.js +22 -13
  39. package/lib/cmap/connection_pool.js.map +1 -1
  40. package/lib/cmap/handshake/client_metadata.js +2 -2
  41. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  42. package/lib/cmap/wire_protocol/compression.js +8 -8
  43. package/lib/cmap/wire_protocol/compression.js.map +1 -1
  44. package/lib/cmap/wire_protocol/on_demand/document.js +218 -0
  45. package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
  46. package/lib/cmap/wire_protocol/responses.js +184 -0
  47. package/lib/cmap/wire_protocol/responses.js.map +1 -0
  48. package/lib/collection.js +42 -38
  49. package/lib/collection.js.map +1 -1
  50. package/lib/connection_string.js +4 -6
  51. package/lib/connection_string.js.map +1 -1
  52. package/lib/cursor/abstract_cursor.js +76 -43
  53. package/lib/cursor/abstract_cursor.js.map +1 -1
  54. package/lib/cursor/aggregation_cursor.js +16 -33
  55. package/lib/cursor/aggregation_cursor.js.map +1 -1
  56. package/lib/cursor/find_cursor.js +36 -18
  57. package/lib/cursor/find_cursor.js.map +1 -1
  58. package/lib/cursor/run_command_cursor.js +3 -2
  59. package/lib/cursor/run_command_cursor.js.map +1 -1
  60. package/lib/db.js +15 -19
  61. package/lib/db.js.map +1 -1
  62. package/lib/deps.js +31 -26
  63. package/lib/deps.js.map +1 -1
  64. package/lib/encrypter.js +14 -5
  65. package/lib/encrypter.js.map +1 -1
  66. package/lib/error.js +4 -3
  67. package/lib/error.js.map +1 -1
  68. package/lib/gridfs/download.js +19 -14
  69. package/lib/gridfs/download.js.map +1 -1
  70. package/lib/gridfs/index.js.map +1 -1
  71. package/lib/gridfs/upload.js +6 -1
  72. package/lib/gridfs/upload.js.map +1 -1
  73. package/lib/index.js.map +1 -1
  74. package/lib/mongo_client.js +11 -7
  75. package/lib/mongo_client.js.map +1 -1
  76. package/lib/mongo_logger.js +3 -0
  77. package/lib/mongo_logger.js.map +1 -1
  78. package/lib/operations/aggregate.js +2 -1
  79. package/lib/operations/aggregate.js.map +1 -1
  80. package/lib/operations/command.js +1 -1
  81. package/lib/operations/command.js.map +1 -1
  82. package/lib/operations/create_collection.js +1 -1
  83. package/lib/operations/create_collection.js.map +1 -1
  84. package/lib/operations/delete.js +4 -3
  85. package/lib/operations/delete.js.map +1 -1
  86. package/lib/operations/drop.js +1 -1
  87. package/lib/operations/drop.js.map +1 -1
  88. package/lib/operations/execute_operation.js +23 -8
  89. package/lib/operations/execute_operation.js.map +1 -1
  90. package/lib/operations/find.js +4 -4
  91. package/lib/operations/find.js.map +1 -1
  92. package/lib/operations/get_more.js +2 -1
  93. package/lib/operations/get_more.js.map +1 -1
  94. package/lib/operations/indexes.js +29 -121
  95. package/lib/operations/indexes.js.map +1 -1
  96. package/lib/operations/insert.js +3 -3
  97. package/lib/operations/insert.js.map +1 -1
  98. package/lib/operations/kill_cursors.js +3 -1
  99. package/lib/operations/kill_cursors.js.map +1 -1
  100. package/lib/operations/list_collections.js +1 -1
  101. package/lib/operations/list_collections.js.map +1 -1
  102. package/lib/operations/list_databases.js +1 -1
  103. package/lib/operations/list_databases.js.map +1 -1
  104. package/lib/operations/operation.js.map +1 -1
  105. package/lib/operations/run_command.js +4 -2
  106. package/lib/operations/run_command.js.map +1 -1
  107. package/lib/operations/search_indexes/create.js.map +1 -1
  108. package/lib/operations/stats.js +1 -1
  109. package/lib/operations/stats.js.map +1 -1
  110. package/lib/operations/update.js +1 -1
  111. package/lib/operations/update.js.map +1 -1
  112. package/lib/sdam/common.js.map +1 -1
  113. package/lib/sdam/monitor.js +139 -42
  114. package/lib/sdam/monitor.js.map +1 -1
  115. package/lib/sdam/server.js +5 -15
  116. package/lib/sdam/server.js.map +1 -1
  117. package/lib/sdam/server_description.js +1 -0
  118. package/lib/sdam/server_description.js.map +1 -1
  119. package/lib/sdam/server_selection.js +1 -1
  120. package/lib/sdam/server_selection.js.map +1 -1
  121. package/lib/sdam/srv_polling.js +2 -1
  122. package/lib/sdam/srv_polling.js.map +1 -1
  123. package/lib/sdam/topology.js +67 -54
  124. package/lib/sdam/topology.js.map +1 -1
  125. package/lib/sdam/topology_description.js +10 -0
  126. package/lib/sdam/topology_description.js.map +1 -1
  127. package/lib/sessions.js +133 -93
  128. package/lib/sessions.js.map +1 -1
  129. package/lib/timeout.js +77 -0
  130. package/lib/timeout.js.map +1 -0
  131. package/lib/utils.js +61 -28
  132. package/lib/utils.js.map +1 -1
  133. package/mongodb.d.ts +150 -38
  134. package/package.json +16 -13
  135. package/src/admin.ts +9 -9
  136. package/src/bson.ts +14 -0
  137. package/src/bulk/common.ts +3 -2
  138. package/src/change_stream.ts +39 -30
  139. package/src/client-side-encryption/auto_encrypter.ts +2 -2
  140. package/src/client-side-encryption/client_encryption.ts +6 -6
  141. package/src/client-side-encryption/providers/aws.ts +17 -10
  142. package/src/client-side-encryption/providers/azure.ts +5 -3
  143. package/src/cmap/auth/aws_temporary_credentials.ts +169 -0
  144. package/src/cmap/auth/gssapi.ts +9 -11
  145. package/src/cmap/auth/mongodb_aws.ts +19 -126
  146. package/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +1 -1
  147. package/src/cmap/auth/mongodb_oidc/callback_lock_cache.ts +2 -1
  148. package/src/cmap/auth/mongodb_oidc/service_workflow.ts +1 -1
  149. package/src/cmap/auth/scram.ts +2 -2
  150. package/src/cmap/commands.ts +28 -132
  151. package/src/cmap/connect.ts +4 -4
  152. package/src/cmap/connection.ts +107 -43
  153. package/src/cmap/connection_pool.ts +32 -29
  154. package/src/cmap/handshake/client_metadata.ts +2 -5
  155. package/src/cmap/wire_protocol/compression.ts +11 -13
  156. package/src/cmap/wire_protocol/on_demand/document.ts +338 -0
  157. package/src/cmap/wire_protocol/responses.ts +237 -0
  158. package/src/collection.ts +87 -58
  159. package/src/connection_string.ts +9 -7
  160. package/src/cursor/abstract_cursor.ts +102 -38
  161. package/src/cursor/aggregation_cursor.ts +32 -34
  162. package/src/cursor/find_cursor.ts +33 -21
  163. package/src/cursor/list_search_indexes_cursor.ts +1 -1
  164. package/src/cursor/run_command_cursor.ts +3 -2
  165. package/src/db.ts +42 -21
  166. package/src/deps.ts +52 -40
  167. package/src/encrypter.ts +14 -5
  168. package/src/error.ts +9 -3
  169. package/src/gridfs/download.ts +19 -31
  170. package/src/gridfs/index.ts +2 -0
  171. package/src/gridfs/upload.ts +11 -8
  172. package/src/index.ts +13 -5
  173. package/src/mongo_client.ts +21 -15
  174. package/src/mongo_logger.ts +3 -0
  175. package/src/mongo_types.ts +1 -1
  176. package/src/operations/aggregate.ts +2 -1
  177. package/src/operations/command.ts +1 -1
  178. package/src/operations/create_collection.ts +7 -2
  179. package/src/operations/delete.ts +4 -3
  180. package/src/operations/drop.ts +1 -1
  181. package/src/operations/execute_operation.ts +29 -10
  182. package/src/operations/find.ts +13 -14
  183. package/src/operations/get_more.ts +9 -1
  184. package/src/operations/indexes.ts +103 -176
  185. package/src/operations/insert.ts +2 -2
  186. package/src/operations/kill_cursors.ts +3 -2
  187. package/src/operations/list_collections.ts +5 -1
  188. package/src/operations/list_databases.ts +1 -1
  189. package/src/operations/operation.ts +3 -0
  190. package/src/operations/run_command.ts +6 -4
  191. package/src/operations/search_indexes/create.ts +4 -1
  192. package/src/operations/stats.ts +1 -1
  193. package/src/operations/update.ts +7 -7
  194. package/src/sdam/common.ts +8 -2
  195. package/src/sdam/monitor.ts +178 -61
  196. package/src/sdam/server.ts +27 -20
  197. package/src/sdam/server_description.ts +8 -3
  198. package/src/sdam/server_selection.ts +2 -3
  199. package/src/sdam/srv_polling.ts +3 -2
  200. package/src/sdam/topology.ts +114 -117
  201. package/src/sdam/topology_description.ts +14 -4
  202. package/src/sessions.ts +168 -148
  203. package/src/timeout.ts +96 -0
  204. package/src/utils.ts +85 -32
  205. package/lib/operations/common_functions.js +0 -38
  206. package/lib/operations/common_functions.js.map +0 -1
  207. package/src/operations/common_functions.ts +0 -79
package/src/collection.ts CHANGED
@@ -24,7 +24,6 @@ import type {
24
24
  } from './mongo_types';
25
25
  import type { AggregateOptions } from './operations/aggregate';
26
26
  import { BulkWriteOperation } from './operations/bulk_write';
27
- import type { IndexInformationOptions } from './operations/common_functions';
28
27
  import { CountOperation, type CountOptions } from './operations/count';
29
28
  import { CountDocumentsOperation, type CountDocumentsOptions } from './operations/count_documents';
30
29
  import {
@@ -49,19 +48,17 @@ import {
49
48
  FindOneAndUpdateOperation,
50
49
  type FindOneAndUpdateOptions
51
50
  } from './operations/find_and_modify';
52
- import {
53
- CreateIndexesOperation,
54
- type CreateIndexesOptions,
55
- CreateIndexOperation,
56
- type DropIndexesOptions,
57
- DropIndexOperation,
58
- type IndexDescription,
59
- IndexesOperation,
60
- IndexExistsOperation,
61
- IndexInformationOperation,
62
- type IndexSpecification,
63
- type ListIndexesOptions
51
+ import type {
52
+ CreateIndexesOptions,
53
+ DropIndexesOptions,
54
+ IndexDescription,
55
+ IndexDescriptionCompact,
56
+ IndexDescriptionInfo,
57
+ IndexInformationOptions,
58
+ IndexSpecification,
59
+ ListIndexesOptions
64
60
  } from './operations/indexes';
61
+ import { CreateIndexesOperation, DropIndexOperation } from './operations/indexes';
65
62
  import {
66
63
  InsertManyOperation,
67
64
  type InsertManyResult,
@@ -110,6 +107,8 @@ export interface CollectionOptions extends BSONSerializeOptions, WriteConcernOpt
110
107
  readConcern?: ReadConcernLike;
111
108
  /** The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). */
112
109
  readPreference?: ReadPreferenceLike;
110
+ /** @internal TODO(NODE-5688): make this public */
111
+ timeoutMS?: number;
113
112
  }
114
113
 
115
114
  /** @internal */
@@ -267,7 +266,7 @@ export class Collection<TSchema extends Document = Document> {
267
266
  doc: OptionalUnlessRequiredId<TSchema>,
268
267
  options?: InsertOneOptions
269
268
  ): Promise<InsertOneResult<TSchema>> {
270
- return executeOperation(
269
+ return await executeOperation(
271
270
  this.client,
272
271
  new InsertOneOperation(
273
272
  this as TODO_NODE_3286,
@@ -289,7 +288,7 @@ export class Collection<TSchema extends Document = Document> {
289
288
  docs: OptionalUnlessRequiredId<TSchema>[],
290
289
  options?: BulkWriteOptions
291
290
  ): Promise<InsertManyResult<TSchema>> {
292
- return executeOperation(
291
+ return await executeOperation(
293
292
  this.client,
294
293
  new InsertManyOperation(
295
294
  this as TODO_NODE_3286,
@@ -326,7 +325,7 @@ export class Collection<TSchema extends Document = Document> {
326
325
  throw new MongoInvalidArgumentError('Argument "operations" must be an array of documents');
327
326
  }
328
327
 
329
- return executeOperation(
328
+ return await executeOperation(
330
329
  this.client,
331
330
  new BulkWriteOperation(
332
331
  this as TODO_NODE_3286,
@@ -352,7 +351,7 @@ export class Collection<TSchema extends Document = Document> {
352
351
  update: UpdateFilter<TSchema> | Document[],
353
352
  options?: UpdateOptions
354
353
  ): Promise<UpdateResult<TSchema>> {
355
- return executeOperation(
354
+ return await executeOperation(
356
355
  this.client,
357
356
  new UpdateOneOperation(
358
357
  this as TODO_NODE_3286,
@@ -375,7 +374,7 @@ export class Collection<TSchema extends Document = Document> {
375
374
  replacement: WithoutId<TSchema>,
376
375
  options?: ReplaceOptions
377
376
  ): Promise<UpdateResult<TSchema> | Document> {
378
- return executeOperation(
377
+ return await executeOperation(
379
378
  this.client,
380
379
  new ReplaceOneOperation(
381
380
  this as TODO_NODE_3286,
@@ -402,7 +401,7 @@ export class Collection<TSchema extends Document = Document> {
402
401
  update: UpdateFilter<TSchema> | Document[],
403
402
  options?: UpdateOptions
404
403
  ): Promise<UpdateResult<TSchema>> {
405
- return executeOperation(
404
+ return await executeOperation(
406
405
  this.client,
407
406
  new UpdateManyOperation(
408
407
  this as TODO_NODE_3286,
@@ -423,7 +422,7 @@ export class Collection<TSchema extends Document = Document> {
423
422
  filter: Filter<TSchema> = {},
424
423
  options: DeleteOptions = {}
425
424
  ): Promise<DeleteResult> {
426
- return executeOperation(
425
+ return await executeOperation(
427
426
  this.client,
428
427
  new DeleteOneOperation(this as TODO_NODE_3286, filter, resolveOptions(this, options))
429
428
  );
@@ -439,7 +438,7 @@ export class Collection<TSchema extends Document = Document> {
439
438
  filter: Filter<TSchema> = {},
440
439
  options: DeleteOptions = {}
441
440
  ): Promise<DeleteResult> {
442
- return executeOperation(
441
+ return await executeOperation(
443
442
  this.client,
444
443
  new DeleteManyOperation(this as TODO_NODE_3286, filter, resolveOptions(this, options))
445
444
  );
@@ -456,7 +455,7 @@ export class Collection<TSchema extends Document = Document> {
456
455
  */
457
456
  async rename(newName: string, options?: RenameOptions): Promise<Collection> {
458
457
  // Intentionally, we do not inherit options from parent for this operation.
459
- return executeOperation(
458
+ return await executeOperation(
460
459
  this.client,
461
460
  new RenameOperation(this as TODO_NODE_3286, newName, {
462
461
  ...options,
@@ -471,7 +470,7 @@ export class Collection<TSchema extends Document = Document> {
471
470
  * @param options - Optional settings for the command
472
471
  */
473
472
  async drop(options?: DropCollectionOptions): Promise<boolean> {
474
- return executeOperation(
473
+ return await executeOperation(
475
474
  this.client,
476
475
  new DropCollectionOperation(this.s.db, this.collectionName, options)
477
476
  );
@@ -525,7 +524,7 @@ export class Collection<TSchema extends Document = Document> {
525
524
  * @param options - Optional settings for the command
526
525
  */
527
526
  async options(options?: OperationOptions): Promise<Document> {
528
- return executeOperation(
527
+ return await executeOperation(
529
528
  this.client,
530
529
  new OptionsOperation(this as TODO_NODE_3286, resolveOptions(this, options))
531
530
  );
@@ -537,7 +536,7 @@ export class Collection<TSchema extends Document = Document> {
537
536
  * @param options - Optional settings for the command
538
537
  */
539
538
  async isCapped(options?: OperationOptions): Promise<boolean> {
540
- return executeOperation(
539
+ return await executeOperation(
541
540
  this.client,
542
541
  new IsCappedOperation(this as TODO_NODE_3286, resolveOptions(this, options))
543
542
  );
@@ -575,15 +574,17 @@ export class Collection<TSchema extends Document = Document> {
575
574
  indexSpec: IndexSpecification,
576
575
  options?: CreateIndexesOptions
577
576
  ): Promise<string> {
578
- return executeOperation(
577
+ const indexes = await executeOperation(
579
578
  this.client,
580
- new CreateIndexOperation(
581
- this as TODO_NODE_3286,
579
+ CreateIndexesOperation.fromIndexSpecification(
580
+ this,
582
581
  this.collectionName,
583
582
  indexSpec,
584
583
  resolveOptions(this, options)
585
584
  )
586
585
  );
586
+
587
+ return indexes[0];
587
588
  }
588
589
 
589
590
  /**
@@ -621,10 +622,10 @@ export class Collection<TSchema extends Document = Document> {
621
622
  indexSpecs: IndexDescription[],
622
623
  options?: CreateIndexesOptions
623
624
  ): Promise<string[]> {
624
- return executeOperation(
625
+ return await executeOperation(
625
626
  this.client,
626
- new CreateIndexesOperation(
627
- this as TODO_NODE_3286,
627
+ CreateIndexesOperation.fromIndexDescriptionArray(
628
+ this,
628
629
  this.collectionName,
629
630
  indexSpecs,
630
631
  resolveOptions(this, { ...options, maxTimeMS: undefined })
@@ -639,7 +640,7 @@ export class Collection<TSchema extends Document = Document> {
639
640
  * @param options - Optional settings for the command
640
641
  */
641
642
  async dropIndex(indexName: string, options?: DropIndexesOptions): Promise<Document> {
642
- return executeOperation(
643
+ return await executeOperation(
643
644
  this.client,
644
645
  new DropIndexOperation(this as TODO_NODE_3286, indexName, {
645
646
  ...resolveOptions(this, options),
@@ -680,14 +681,14 @@ export class Collection<TSchema extends Document = Document> {
680
681
  * @param indexes - One or more index names to check.
681
682
  * @param options - Optional settings for the command
682
683
  */
683
- async indexExists(
684
- indexes: string | string[],
685
- options?: IndexInformationOptions
686
- ): Promise<boolean> {
687
- return executeOperation(
688
- this.client,
689
- new IndexExistsOperation(this as TODO_NODE_3286, indexes, resolveOptions(this, options))
684
+ async indexExists(indexes: string | string[], options?: ListIndexesOptions): Promise<boolean> {
685
+ const indexNames: string[] = Array.isArray(indexes) ? indexes : [indexes];
686
+ const allIndexes: Set<string> = new Set(
687
+ await this.listIndexes(options)
688
+ .map(({ name }) => name)
689
+ .toArray()
690
690
  );
691
+ return indexNames.every(name => allIndexes.has(name));
691
692
  }
692
693
 
693
694
  /**
@@ -695,11 +696,23 @@ export class Collection<TSchema extends Document = Document> {
695
696
  *
696
697
  * @param options - Optional settings for the command
697
698
  */
698
- async indexInformation(options?: IndexInformationOptions): Promise<Document> {
699
- return executeOperation(
700
- this.client,
701
- new IndexInformationOperation(this.s.db, this.collectionName, resolveOptions(this, options))
702
- );
699
+ indexInformation(
700
+ options: IndexInformationOptions & { full: true }
701
+ ): Promise<IndexDescriptionInfo[]>;
702
+ indexInformation(
703
+ options: IndexInformationOptions & { full?: false }
704
+ ): Promise<IndexDescriptionCompact>;
705
+ indexInformation(
706
+ options: IndexInformationOptions
707
+ ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
708
+ indexInformation(): Promise<IndexDescriptionCompact>;
709
+ async indexInformation(
710
+ options?: IndexInformationOptions
711
+ ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]> {
712
+ return await this.indexes({
713
+ ...options,
714
+ full: options?.full ?? false
715
+ });
703
716
  }
704
717
 
705
718
  /**
@@ -716,7 +729,7 @@ export class Collection<TSchema extends Document = Document> {
716
729
  * @param options - Optional settings for the command
717
730
  */
718
731
  async estimatedDocumentCount(options?: EstimatedDocumentCountOptions): Promise<number> {
719
- return executeOperation(
732
+ return await executeOperation(
720
733
  this.client,
721
734
  new EstimatedDocumentCountOperation(this as TODO_NODE_3286, resolveOptions(this, options))
722
735
  );
@@ -751,7 +764,7 @@ export class Collection<TSchema extends Document = Document> {
751
764
  filter: Filter<TSchema> = {},
752
765
  options: CountDocumentsOptions = {}
753
766
  ): Promise<number> {
754
- return executeOperation(
767
+ return await executeOperation(
755
768
  this.client,
756
769
  new CountDocumentsOperation(this as TODO_NODE_3286, filter, resolveOptions(this, options))
757
770
  );
@@ -787,7 +800,7 @@ export class Collection<TSchema extends Document = Document> {
787
800
  filter: Filter<TSchema> = {},
788
801
  options: DistinctOptions = {}
789
802
  ): Promise<any[]> {
790
- return executeOperation(
803
+ return await executeOperation(
791
804
  this.client,
792
805
  new DistinctOperation(
793
806
  this as TODO_NODE_3286,
@@ -803,11 +816,26 @@ export class Collection<TSchema extends Document = Document> {
803
816
  *
804
817
  * @param options - Optional settings for the command
805
818
  */
806
- async indexes(options?: IndexInformationOptions): Promise<Document[]> {
807
- return executeOperation(
808
- this.client,
809
- new IndexesOperation(this as TODO_NODE_3286, resolveOptions(this, options))
819
+ indexes(options: IndexInformationOptions & { full?: true }): Promise<IndexDescriptionInfo[]>;
820
+ indexes(options: IndexInformationOptions & { full: false }): Promise<IndexDescriptionCompact>;
821
+ indexes(
822
+ options: IndexInformationOptions
823
+ ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
824
+ indexes(options?: ListIndexesOptions): Promise<IndexDescriptionInfo[]>;
825
+ async indexes(
826
+ options?: IndexInformationOptions
827
+ ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]> {
828
+ const indexes: IndexDescriptionInfo[] = await this.listIndexes(options).toArray();
829
+ const full = options?.full ?? true;
830
+ if (full) {
831
+ return indexes;
832
+ }
833
+
834
+ const object: IndexDescriptionCompact = Object.fromEntries(
835
+ indexes.map(({ name, key }) => [name, Object.entries(key)])
810
836
  );
837
+
838
+ return object;
811
839
  }
812
840
 
813
841
  /**
@@ -833,7 +861,7 @@ export class Collection<TSchema extends Document = Document> {
833
861
  filter: Filter<TSchema>,
834
862
  options?: FindOneAndDeleteOptions
835
863
  ): Promise<WithId<TSchema> | ModifyResult<TSchema> | null> {
836
- return executeOperation(
864
+ return await executeOperation(
837
865
  this.client,
838
866
  new FindOneAndDeleteOperation(
839
867
  this as TODO_NODE_3286,
@@ -874,7 +902,7 @@ export class Collection<TSchema extends Document = Document> {
874
902
  replacement: WithoutId<TSchema>,
875
903
  options?: FindOneAndReplaceOptions
876
904
  ): Promise<WithId<TSchema> | ModifyResult<TSchema> | null> {
877
- return executeOperation(
905
+ return await executeOperation(
878
906
  this.client,
879
907
  new FindOneAndReplaceOperation(
880
908
  this as TODO_NODE_3286,
@@ -916,7 +944,7 @@ export class Collection<TSchema extends Document = Document> {
916
944
  update: UpdateFilter<TSchema>,
917
945
  options?: FindOneAndUpdateOptions
918
946
  ): Promise<WithId<TSchema> | ModifyResult<TSchema> | null> {
919
- return executeOperation(
947
+ return await executeOperation(
920
948
  this.client,
921
949
  new FindOneAndUpdateOperation(
922
950
  this as TODO_NODE_3286,
@@ -1039,7 +1067,7 @@ export class Collection<TSchema extends Document = Document> {
1039
1067
  * @param options - Optional settings for the command
1040
1068
  */
1041
1069
  async count(filter: Filter<TSchema> = {}, options: CountOptions = {}): Promise<number> {
1042
- return executeOperation(
1070
+ return await executeOperation(
1043
1071
  this.client,
1044
1072
  new CountOperation(this.fullNamespace, filter, resolveOptions(this, options))
1045
1073
  );
@@ -1068,6 +1096,7 @@ export class Collection<TSchema extends Document = Document> {
1068
1096
  ): ListSearchIndexesCursor {
1069
1097
  options =
1070
1098
  typeof indexNameOrOptions === 'object' ? indexNameOrOptions : options == null ? {} : options;
1099
+
1071
1100
  const indexName =
1072
1101
  indexNameOrOptions == null
1073
1102
  ? null
@@ -1101,7 +1130,7 @@ export class Collection<TSchema extends Document = Document> {
1101
1130
  * @returns
1102
1131
  */
1103
1132
  async createSearchIndexes(descriptions: SearchIndexDescription[]): Promise<string[]> {
1104
- return executeOperation(
1133
+ return await executeOperation(
1105
1134
  this.client,
1106
1135
  new CreateSearchIndexesOperation(this as TODO_NODE_3286, descriptions)
1107
1136
  );
@@ -1115,7 +1144,7 @@ export class Collection<TSchema extends Document = Document> {
1115
1144
  * @remarks Only available when used against a 7.0+ Atlas cluster.
1116
1145
  */
1117
1146
  async dropSearchIndex(name: string): Promise<void> {
1118
- return executeOperation(
1147
+ return await executeOperation(
1119
1148
  this.client,
1120
1149
  new DropSearchIndexOperation(this as TODO_NODE_3286, name)
1121
1150
  );
@@ -1130,7 +1159,7 @@ export class Collection<TSchema extends Document = Document> {
1130
1159
  * @remarks Only available when used against a 7.0+ Atlas cluster.
1131
1160
  */
1132
1161
  async updateSearchIndex(name: string, definition: Document): Promise<void> {
1133
- return executeOperation(
1162
+ return await executeOperation(
1134
1163
  this.client,
1135
1164
  new UpdateSearchIndexOperation(this as TODO_NODE_3286, name, definition)
1136
1165
  );
@@ -40,7 +40,8 @@ import {
40
40
  isRecord,
41
41
  matchesParentDomain,
42
42
  parseInteger,
43
- setDifference
43
+ setDifference,
44
+ squashError
44
45
  } from './utils';
45
46
  import { type W, WriteConcern } from './write_concern';
46
47
 
@@ -72,9 +73,8 @@ export async function resolveSRVRecord(options: MongoOptions): Promise<HostAddre
72
73
  // the SRV record is resolved before starting a second DNS query.
73
74
  const lookupAddress = options.srvHost;
74
75
  const txtResolutionPromise = dns.promises.resolveTxt(lookupAddress);
75
- txtResolutionPromise.catch(() => {
76
- /* rejections will be handled later */
77
- });
76
+ // eslint-disable-next-line github/no-then
77
+ txtResolutionPromise.then(undefined, squashError); // rejections will be handled later
78
78
 
79
79
  // Resolve the SRV record and use the result as the list of hosts to connect to.
80
80
  const addresses = await dns.promises.resolveSrv(
@@ -552,9 +552,11 @@ export function parseOptions(
552
552
 
553
553
  mongoOptions.metadata = makeClientMetadata(mongoOptions);
554
554
 
555
- mongoOptions.extendedMetadata = addContainerMetadata(mongoOptions.metadata).catch(() => {
556
- /* rejections will be handled later */
557
- });
555
+ // eslint-disable-next-line github/no-then
556
+ mongoOptions.extendedMetadata = addContainerMetadata(mongoOptions.metadata).then(
557
+ undefined,
558
+ squashError
559
+ ); // rejections will be handled later
558
560
 
559
561
  return mongoOptions;
560
562
  }