mongodb 4.1.3 → 4.2.2

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 (168) hide show
  1. package/README.md +15 -14
  2. package/lib/admin.js +5 -5
  3. package/lib/admin.js.map +1 -1
  4. package/lib/bson.js.map +1 -1
  5. package/lib/bulk/common.js +54 -56
  6. package/lib/bulk/common.js.map +1 -1
  7. package/lib/change_stream.js +13 -14
  8. package/lib/change_stream.js.map +1 -1
  9. package/lib/cmap/auth/gssapi.js +1 -1
  10. package/lib/cmap/auth/gssapi.js.map +1 -1
  11. package/lib/cmap/auth/mongocr.js +2 -2
  12. package/lib/cmap/auth/mongocr.js.map +1 -1
  13. package/lib/cmap/auth/mongodb_aws.js +3 -3
  14. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  15. package/lib/cmap/auth/plain.js +1 -1
  16. package/lib/cmap/auth/plain.js.map +1 -1
  17. package/lib/cmap/auth/scram.js +5 -5
  18. package/lib/cmap/auth/scram.js.map +1 -1
  19. package/lib/cmap/auth/x509.js +1 -1
  20. package/lib/cmap/auth/x509.js.map +1 -1
  21. package/lib/cmap/command_monitoring_events.js +15 -15
  22. package/lib/cmap/command_monitoring_events.js.map +1 -1
  23. package/lib/cmap/commands.js +10 -7
  24. package/lib/cmap/commands.js.map +1 -1
  25. package/lib/cmap/connect.js +2 -2
  26. package/lib/cmap/connect.js.map +1 -1
  27. package/lib/cmap/connection.js +15 -15
  28. package/lib/cmap/connection.js.map +1 -1
  29. package/lib/cmap/connection_pool.js +3 -3
  30. package/lib/cmap/connection_pool.js.map +1 -1
  31. package/lib/cmap/message_stream.js +2 -2
  32. package/lib/cmap/message_stream.js.map +1 -1
  33. package/lib/cmap/stream_description.js +4 -4
  34. package/lib/cmap/stream_description.js.map +1 -1
  35. package/lib/cmap/wire_protocol/constants.js +4 -4
  36. package/lib/collection.js +42 -41
  37. package/lib/collection.js.map +1 -1
  38. package/lib/connection_string.js +73 -45
  39. package/lib/connection_string.js.map +1 -1
  40. package/lib/cursor/abstract_cursor.js +16 -13
  41. package/lib/cursor/abstract_cursor.js.map +1 -1
  42. package/lib/cursor/aggregation_cursor.js +14 -14
  43. package/lib/cursor/aggregation_cursor.js.map +1 -1
  44. package/lib/cursor/find_cursor.js +23 -23
  45. package/lib/cursor/find_cursor.js.map +1 -1
  46. package/lib/db.js +20 -20
  47. package/lib/db.js.map +1 -1
  48. package/lib/deps.js +1 -1
  49. package/lib/deps.js.map +1 -1
  50. package/lib/error.js +47 -24
  51. package/lib/error.js.map +1 -1
  52. package/lib/gridfs/index.js +3 -3
  53. package/lib/gridfs/index.js.map +1 -1
  54. package/lib/gridfs/upload.js +1 -1
  55. package/lib/gridfs/upload.js.map +1 -1
  56. package/lib/logger.js +5 -5
  57. package/lib/logger.js.map +1 -1
  58. package/lib/mongo_client.js +7 -7
  59. package/lib/mongo_client.js.map +1 -1
  60. package/lib/mongo_types.js.map +1 -1
  61. package/lib/operations/add_user.js +3 -3
  62. package/lib/operations/add_user.js.map +1 -1
  63. package/lib/operations/aggregate.js +3 -4
  64. package/lib/operations/aggregate.js.map +1 -1
  65. package/lib/operations/bulk_write.js +1 -1
  66. package/lib/operations/bulk_write.js.map +1 -1
  67. package/lib/operations/command.js +7 -3
  68. package/lib/operations/command.js.map +1 -1
  69. package/lib/operations/common_functions.js +1 -1
  70. package/lib/operations/common_functions.js.map +1 -1
  71. package/lib/operations/connect.js +1 -1
  72. package/lib/operations/connect.js.map +1 -1
  73. package/lib/operations/count.js +1 -1
  74. package/lib/operations/count.js.map +1 -1
  75. package/lib/operations/create_collection.js +1 -1
  76. package/lib/operations/create_collection.js.map +1 -1
  77. package/lib/operations/delete.js +6 -6
  78. package/lib/operations/delete.js.map +1 -1
  79. package/lib/operations/distinct.js +4 -4
  80. package/lib/operations/distinct.js.map +1 -1
  81. package/lib/operations/drop.js +2 -2
  82. package/lib/operations/drop.js.map +1 -1
  83. package/lib/operations/estimated_document_count.js +2 -2
  84. package/lib/operations/estimated_document_count.js.map +1 -1
  85. package/lib/operations/execute_operation.js +24 -7
  86. package/lib/operations/execute_operation.js.map +1 -1
  87. package/lib/operations/find.js +8 -8
  88. package/lib/operations/find.js.map +1 -1
  89. package/lib/operations/find_and_modify.js +7 -7
  90. package/lib/operations/find_and_modify.js.map +1 -1
  91. package/lib/operations/get_more.js +28 -0
  92. package/lib/operations/get_more.js.map +1 -0
  93. package/lib/operations/indexes.js +14 -14
  94. package/lib/operations/indexes.js.map +1 -1
  95. package/lib/operations/insert.js +5 -5
  96. package/lib/operations/insert.js.map +1 -1
  97. package/lib/operations/list_collections.js +12 -7
  98. package/lib/operations/list_collections.js.map +1 -1
  99. package/lib/operations/list_databases.js +1 -1
  100. package/lib/operations/list_databases.js.map +1 -1
  101. package/lib/operations/map_reduce.js +6 -6
  102. package/lib/operations/map_reduce.js.map +1 -1
  103. package/lib/operations/operation.js +4 -2
  104. package/lib/operations/operation.js.map +1 -1
  105. package/lib/operations/remove_user.js +1 -1
  106. package/lib/operations/remove_user.js.map +1 -1
  107. package/lib/operations/rename.js +2 -2
  108. package/lib/operations/rename.js.map +1 -1
  109. package/lib/operations/set_profiling_level.js +1 -1
  110. package/lib/operations/set_profiling_level.js.map +1 -1
  111. package/lib/operations/stats.js +2 -2
  112. package/lib/operations/stats.js.map +1 -1
  113. package/lib/operations/update.js +12 -12
  114. package/lib/operations/update.js.map +1 -1
  115. package/lib/read_preference.js +4 -1
  116. package/lib/read_preference.js.map +1 -1
  117. package/lib/sdam/monitor.js +14 -14
  118. package/lib/sdam/monitor.js.map +1 -1
  119. package/lib/sdam/server.js +19 -12
  120. package/lib/sdam/server.js.map +1 -1
  121. package/lib/sdam/server_description.js +3 -3
  122. package/lib/sdam/server_description.js.map +1 -1
  123. package/lib/sdam/server_selection.js +36 -1
  124. package/lib/sdam/server_selection.js.map +1 -1
  125. package/lib/sdam/srv_polling.js +9 -9
  126. package/lib/sdam/srv_polling.js.map +1 -1
  127. package/lib/sdam/topology.js +29 -21
  128. package/lib/sdam/topology.js.map +1 -1
  129. package/lib/sdam/topology_description.js +34 -12
  130. package/lib/sdam/topology_description.js.map +1 -1
  131. package/lib/sessions.js +19 -19
  132. package/lib/sessions.js.map +1 -1
  133. package/lib/transactions.js.map +1 -1
  134. package/lib/utils.js +53 -46
  135. package/lib/utils.js.map +1 -1
  136. package/mongodb.d.ts +60 -37
  137. package/mongodb.ts34.d.ts +61 -37
  138. package/package.json +26 -30
  139. package/src/bson.ts +1 -0
  140. package/src/bulk/common.ts +50 -37
  141. package/src/change_stream.ts +10 -8
  142. package/src/cmap/commands.ts +11 -8
  143. package/src/cmap/connection.ts +1 -0
  144. package/src/cmap/stream_description.ts +3 -3
  145. package/src/cmap/wire_protocol/constants.ts +4 -4
  146. package/src/collection.ts +40 -25
  147. package/src/connection_string.ts +75 -36
  148. package/src/cursor/abstract_cursor.ts +9 -11
  149. package/src/db.ts +5 -6
  150. package/src/error.ts +51 -23
  151. package/src/mongo_client.ts +12 -0
  152. package/src/mongo_types.ts +11 -14
  153. package/src/operations/aggregate.ts +1 -2
  154. package/src/operations/command.ts +5 -0
  155. package/src/operations/create_collection.ts +1 -1
  156. package/src/operations/execute_operation.ts +22 -2
  157. package/src/operations/get_more.ts +49 -0
  158. package/src/operations/list_collections.ts +12 -4
  159. package/src/operations/operation.ts +5 -1
  160. package/src/read_preference.ts +4 -1
  161. package/src/sdam/server.ts +8 -0
  162. package/src/sdam/server_selection.ts +43 -0
  163. package/src/sdam/srv_polling.ts +12 -11
  164. package/src/sdam/topology.ts +27 -10
  165. package/src/sdam/topology_description.ts +35 -11
  166. package/src/sessions.ts +2 -1
  167. package/src/transactions.ts +2 -2
  168. package/src/utils.ts +67 -56
package/mongodb.d.ts CHANGED
@@ -26,6 +26,7 @@ import { Readable } from 'stream';
26
26
  import type { serialize as serialize_2 } from 'bson';
27
27
  import type { SerializeOptions } from 'bson';
28
28
  import type { Socket } from 'net';
29
+ import type { SrvRecord } from 'dns';
29
30
  import type { TcpNetConnectOpts } from 'net';
30
31
  import { Timestamp } from 'bson';
31
32
  import type { TLSSocket } from 'tls';
@@ -684,7 +685,7 @@ export { BSONRegExp }
684
685
  * BSON Serialization options.
685
686
  * @public
686
687
  */
687
- export declare interface BSONSerializeOptions extends Omit<SerializeOptions, 'index'>, Omit<DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index'> {
688
+ export declare interface BSONSerializeOptions extends Omit<SerializeOptions, 'index'>, Omit<DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index' | 'validation'> {
688
689
  /** Return BSON filled buffers from operations */
689
690
  raw?: boolean;
690
691
  }
@@ -787,8 +788,10 @@ export declare abstract class BulkOperationBase {
787
788
  get bsonOptions(): BSONSerializeOptions;
788
789
  get writeConcern(): WriteConcern | undefined;
789
790
  get batches(): Batch[];
790
- /** An internal helper method. Do not invoke directly. Will be going away in the future */
791
- execute(options?: BulkWriteOptions, callback?: Callback<BulkWriteResult>): Promise<BulkWriteResult> | void;
791
+ execute(options?: BulkWriteOptions): Promise<BulkWriteResult>;
792
+ execute(callback: Callback<BulkWriteResult>): void;
793
+ execute(options: BulkWriteOptions | undefined, callback: Callback<BulkWriteResult>): void;
794
+ execute(options?: BulkWriteOptions | Callback<BulkWriteResult>, callback?: Callback<BulkWriteResult>): Promise<BulkWriteResult> | void;
792
795
  /* Excluded from this release type: handleWriteError */
793
796
  abstract addToOperationsList(batchType: BatchType, document: Document | UpdateStatement | DeleteStatement): this;
794
797
  }
@@ -909,7 +912,7 @@ export declare class CancellationToken extends TypedEventEmitter<{
909
912
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
910
913
  * @public
911
914
  */
912
- export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents> {
915
+ export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents<TSchema>> {
913
916
  pipeline: Document[];
914
917
  options: ChangeStreamOptions;
915
918
  parent: MongoClient | Db | Collection;
@@ -950,7 +953,8 @@ export declare class ChangeStream<TSchema extends Document = Document> extends T
950
953
  /** The cached resume token that is used to resume after the most recently returned change. */
951
954
  get resumeToken(): ResumeToken;
952
955
  /** Check if there is any document still available in the Change Stream */
953
- hasNext(callback?: Callback): Promise<void> | void;
956
+ hasNext(): Promise<boolean>;
957
+ hasNext(callback: Callback<boolean>): void;
954
958
  /** Get the next available document from the Change Stream. */
955
959
  next(): Promise<ChangeStreamDocument<TSchema>>;
956
960
  next(callback: Callback<ChangeStreamDocument<TSchema>>): void;
@@ -1027,14 +1031,14 @@ export declare interface ChangeStreamDocument<TSchema extends Document = Documen
1027
1031
  }
1028
1032
 
1029
1033
  /** @public */
1030
- export declare type ChangeStreamEvents = {
1034
+ export declare type ChangeStreamEvents<TSchema extends Document = Document> = {
1031
1035
  resumeTokenChanged(token: ResumeToken): void;
1032
- init(response: Document): void;
1033
- more(response?: Document | undefined): void;
1036
+ init(response: TSchema): void;
1037
+ more(response?: TSchema | undefined): void;
1034
1038
  response(): void;
1035
1039
  end(): void;
1036
1040
  error(error: Error): void;
1037
- change(change: ChangeStreamDocument): void;
1041
+ change(change: ChangeStreamDocument<TSchema>): void;
1038
1042
  } & AbstractCursorEvents;
1039
1043
 
1040
1044
  /**
@@ -1380,10 +1384,10 @@ export declare class Collection<TSchema extends Document = Document> {
1380
1384
  * @param options - Optional settings for the command
1381
1385
  * @param callback - An optional callback, a Promise will be returned if none is provided
1382
1386
  */
1383
- replaceOne(filter: Filter<TSchema>, replacement: TSchema): Promise<UpdateResult | Document>;
1384
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, callback: Callback<UpdateResult | Document>): void;
1385
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, options: ReplaceOptions): Promise<UpdateResult | Document>;
1386
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, options: ReplaceOptions, callback: Callback<UpdateResult | Document>): void;
1387
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<UpdateResult | Document>;
1388
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<UpdateResult | Document>): void;
1389
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions): Promise<UpdateResult | Document>;
1390
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions, callback: Callback<UpdateResult | Document>): void;
1387
1391
  /**
1388
1392
  * Update multiple documents in a collection
1389
1393
  *
@@ -1449,12 +1453,12 @@ export declare class Collection<TSchema extends Document = Document> {
1449
1453
  * @param options - Optional settings for the command
1450
1454
  * @param callback - An optional callback, a Promise will be returned if none is provided
1451
1455
  */
1452
- findOne(): Promise<TSchema | null>;
1453
- findOne(callback: Callback<TSchema | null>): void;
1454
- findOne(filter: Filter<TSchema>): Promise<TSchema | null>;
1455
- findOne(filter: Filter<TSchema>, callback: Callback<TSchema | null>): void;
1456
- findOne(filter: Filter<TSchema>, options: FindOptions): Promise<TSchema | null>;
1457
- findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<TSchema | null>): void;
1456
+ findOne(): Promise<WithId<TSchema> | null>;
1457
+ findOne(callback: Callback<WithId<TSchema> | null>): void;
1458
+ findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
1459
+ findOne(filter: Filter<TSchema>, callback: Callback<WithId<TSchema> | null>): void;
1460
+ findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
1461
+ findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<WithId<TSchema> | null>): void;
1458
1462
  findOne<T = TSchema>(): Promise<T | null>;
1459
1463
  findOne<T = TSchema>(callback: Callback<T | null>): void;
1460
1464
  findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
@@ -1465,8 +1469,8 @@ export declare class Collection<TSchema extends Document = Document> {
1465
1469
  *
1466
1470
  * @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
1467
1471
  */
1468
- find(): FindCursor<TSchema>;
1469
- find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
1472
+ find(): FindCursor<WithId<TSchema>>;
1473
+ find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
1470
1474
  find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
1471
1475
  /**
1472
1476
  * Returns the options of the collection.
@@ -1707,10 +1711,10 @@ export declare class Collection<TSchema extends Document = Document> {
1707
1711
  * @param options - Optional settings for the command
1708
1712
  * @param callback - An optional callback, a Promise will be returned if none is provided
1709
1713
  */
1710
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document): Promise<ModifyResult<TSchema>>;
1711
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, callback: Callback<ModifyResult<TSchema>>): void;
1712
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, options: FindOneAndReplaceOptions): Promise<ModifyResult<TSchema>>;
1713
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, options: FindOneAndReplaceOptions, callback: Callback<ModifyResult<TSchema>>): void;
1714
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<ModifyResult<TSchema>>;
1715
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
1716
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions): Promise<ModifyResult<TSchema>>;
1717
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions, callback: Callback<ModifyResult<TSchema>>): void;
1714
1718
  /**
1715
1719
  * Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
1716
1720
  *
@@ -1741,6 +1745,7 @@ export declare class Collection<TSchema extends Document = Document> {
1741
1745
  /**
1742
1746
  * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
1743
1747
  *
1748
+ * @deprecated collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.
1744
1749
  * @param map - The mapping function.
1745
1750
  * @param reduce - The reduce function.
1746
1751
  * @param options - Optional settings for the command
@@ -2342,10 +2347,9 @@ export declare class Db {
2342
2347
  * @param options - Optional settings for the command
2343
2348
  * @param callback - An optional callback, a Promise will be returned if none is provided
2344
2349
  */
2345
- createCollection<TSchema extends Document = Document>(name: string): Promise<Collection<TSchema>>;
2350
+ createCollection<TSchema extends Document = Document>(name: string, options?: CreateCollectionOptions): Promise<Collection<TSchema>>;
2346
2351
  createCollection<TSchema extends Document = Document>(name: string, callback: Callback<Collection<TSchema>>): void;
2347
- createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions): Promise<Collection<TSchema>>;
2348
- createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions, callback: Callback<Collection<TSchema>>): void;
2352
+ createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions | undefined, callback: Callback<Collection<TSchema>>): void;
2349
2353
  /**
2350
2354
  * Execute a command
2351
2355
  *
@@ -2733,8 +2737,8 @@ export declare type ExplainVerbosityLike = ExplainVerbosity | boolean;
2733
2737
 
2734
2738
  /** A MongoDB filter can be some portion of the schema or a set of operators @public */
2735
2739
  export declare type Filter<TSchema> = {
2736
- [P in keyof TSchema]?: Condition<TSchema[P]>;
2737
- } & RootFilterOperators<TSchema>;
2740
+ [P in keyof WithId<TSchema>]?: Condition<WithId<TSchema>[P]>;
2741
+ } & RootFilterOperators<WithId<TSchema>>;
2738
2742
 
2739
2743
  /** @public */
2740
2744
  export declare type FilterOperations<T> = T extends Record<string, any> ? {
@@ -3360,11 +3364,13 @@ export declare class HostAddress {
3360
3364
  socketPath: string | undefined;
3361
3365
  isIPv6: boolean | undefined;
3362
3366
  constructor(hostString: string);
3367
+ inspect(): string;
3363
3368
  /**
3364
3369
  * @param ipv6Brackets - optionally request ipv6 bracket notation required for connection strings
3365
3370
  */
3366
3371
  toString(ipv6Brackets?: boolean): string;
3367
3372
  static fromString(s: string): HostAddress;
3373
+ static fromSrvRecord({ name, port }: SrvRecord): HostAddress;
3368
3374
  }
3369
3375
 
3370
3376
  /** @public */
@@ -3602,6 +3608,8 @@ export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name'
3602
3608
  export declare interface ListCollectionsOptions extends CommandOperationOptions {
3603
3609
  /** Since 4.0: If true, will only return the collection name in the response, and will omit additional info */
3604
3610
  nameOnly?: boolean;
3611
+ /** Since 4.0: If true and nameOnly is true, allows a user without the required privilege (i.e. listCollections action on the database) to run the command when access control is enforced. */
3612
+ authorizedCollections?: boolean;
3605
3613
  /** The batchSize for the returned command cursor or if pre 2.8 the systems batch collection */
3606
3614
  batchSize?: number;
3607
3615
  }
@@ -4029,6 +4037,16 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
4029
4037
  compressors?: CompressorName[] | string;
4030
4038
  /** An integer that specifies the compression level if using zlib for network compression. */
4031
4039
  zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
4040
+ /** The maximum number of hosts to connect to when using an srv connection string, a setting of `0` means unlimited hosts */
4041
+ srvMaxHosts?: number;
4042
+ /**
4043
+ * Modifies the srv URI to look like:
4044
+ *
4045
+ * `_{srvServiceName}._tcp.{hostname}.{domainname}`
4046
+ *
4047
+ * Querying this DNS URI is expected to respond with SRV records
4048
+ */
4049
+ srvServiceName?: string;
4032
4050
  /** The maximum number of connections in the connection pool. */
4033
4051
  maxPoolSize?: number;
4034
4052
  /** The minimum number of connections in the connection pool. */
@@ -4411,7 +4429,7 @@ export declare class MongoNotConnectedError extends MongoAPIError {
4411
4429
  * Mongo Client Options
4412
4430
  * @public
4413
4431
  */
4414
- export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
4432
+ export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'srvMaxHosts' | 'srvServiceName' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
4415
4433
  hosts: HostAddress[];
4416
4434
  srvHost?: string;
4417
4435
  credentials?: MongoCredentials;
@@ -4619,6 +4637,7 @@ export declare interface OperationOptions extends BSONSerializeOptions {
4619
4637
  /** The preferred read preference (ReadPreference.primary, ReadPreference.primary_preferred, ReadPreference.secondary, ReadPreference.secondary_preferred, ReadPreference.nearest). */
4620
4638
  readPreference?: ReadPreferenceLike;
4621
4639
  /* Excluded from this release type: bypassPinningCheck */
4640
+ omitReadPreference?: boolean;
4622
4641
  }
4623
4642
 
4624
4643
  /* Excluded from this release type: OperationParent */
@@ -4644,11 +4663,13 @@ export declare type OperationTime = Timestamp;
4644
4663
  * `TSchema['_id'] extends ObjectId` which translated to "Is the _id property ObjectId?"
4645
4664
  * we instead ask "Does ObjectId look like (have the same shape) as the _id?"
4646
4665
  */
4647
- export declare type OptionalId<TSchema extends {
4666
+ export declare type OptionalId<TSchema> = TSchema extends {
4648
4667
  _id?: any;
4649
- }> = ObjectId extends TSchema['_id'] ? EnhancedOmit<TSchema, '_id'> & {
4668
+ } ? ObjectId extends TSchema['_id'] ? EnhancedOmit<TSchema, '_id'> & {
4669
+ _id?: InferIdType<TSchema>;
4670
+ } : WithId<TSchema> : EnhancedOmit<TSchema, '_id'> & {
4650
4671
  _id?: InferIdType<TSchema>;
4651
- } : WithId<TSchema>;
4672
+ };
4652
4673
 
4653
4674
  /** @public */
4654
4675
  export declare class OrderedBulkOperation extends BulkOperationBase {
@@ -4906,7 +4927,7 @@ export declare interface ReplaceOneModel<TSchema extends Document = Document> {
4906
4927
  /** The filter to limit the replaced document. */
4907
4928
  filter: Filter<TSchema>;
4908
4929
  /** The document with which to replace the matched document. */
4909
- replacement: TSchema;
4930
+ replacement: WithoutId<TSchema>;
4910
4931
  /** Specifies a collation. */
4911
4932
  collation?: CollationOptions;
4912
4933
  /** The index to use. If specified, then the query system will only consider plans using the hinted index. */
@@ -5326,7 +5347,7 @@ export declare type TagSet = {
5326
5347
  export declare interface TimeSeriesCollectionOptions extends Document {
5327
5348
  timeField: string;
5328
5349
  metaField?: string;
5329
- granularity?: string;
5350
+ granularity?: 'seconds' | 'minutes' | 'hours' | string;
5330
5351
  }
5331
5352
 
5332
5353
  export { Timestamp }
@@ -5428,6 +5449,8 @@ export declare class TopologyOpeningEvent {
5428
5449
 
5429
5450
  /** @public */
5430
5451
  export declare interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
5452
+ srvMaxHosts: number;
5453
+ srvServiceName: string;
5431
5454
  hosts: HostAddress[];
5432
5455
  retryWrites: boolean;
5433
5456
  retryReads: boolean;
@@ -5500,7 +5523,7 @@ export declare class Transaction {
5500
5523
  */
5501
5524
  export declare interface TransactionOptions extends CommandOperationOptions {
5502
5525
  /** A default read concern for commands in this transaction */
5503
- readConcern?: ReadConcern;
5526
+ readConcern?: ReadConcernLike;
5504
5527
  /** A default writeConcern for commands in this transaction */
5505
5528
  writeConcern?: WriteConcern;
5506
5529
  /** A default read preference for commands in this transaction */
package/mongodb.ts34.d.ts CHANGED
@@ -25,6 +25,7 @@ import { Readable } from 'stream';
25
25
  import { serialize as serialize_2 } from 'bson';
26
26
  import { SerializeOptions } from 'bson';
27
27
  import { Socket } from 'net';
28
+ import { SrvRecord } from 'dns';
28
29
  import { TcpNetConnectOpts } from 'net';
29
30
  import { Timestamp } from 'bson';
30
31
  import { TLSSocket } from 'tls';
@@ -649,7 +650,7 @@ export { BSONRegExp };
649
650
  * BSON Serialization options.
650
651
  * @public
651
652
  */
652
- export declare interface BSONSerializeOptions extends Pick<SerializeOptions, Exclude<keyof SerializeOptions, 'index'>>, Pick<DeserializeOptions, Exclude<keyof DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index'>> {
653
+ export declare interface BSONSerializeOptions extends Pick<SerializeOptions, Exclude<keyof SerializeOptions, 'index'>>, Pick<DeserializeOptions, Exclude<keyof DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index' | 'validation'>> {
653
654
  /** Return BSON filled buffers from operations */
654
655
  raw?: boolean;
655
656
  }
@@ -746,8 +747,10 @@ export declare abstract class BulkOperationBase {
746
747
  readonly bsonOptions: BSONSerializeOptions;
747
748
  readonly writeConcern: WriteConcern | undefined;
748
749
  readonly batches: Batch[];
749
- /** An internal helper method. Do not invoke directly. Will be going away in the future */
750
- execute(options?: BulkWriteOptions, callback?: Callback<BulkWriteResult>): Promise<BulkWriteResult> | void;
750
+ execute(options?: BulkWriteOptions): Promise<BulkWriteResult>;
751
+ execute(callback: Callback<BulkWriteResult>): void;
752
+ execute(options: BulkWriteOptions | undefined, callback: Callback<BulkWriteResult>): void;
753
+ execute(options?: BulkWriteOptions | Callback<BulkWriteResult>, callback?: Callback<BulkWriteResult>): Promise<BulkWriteResult> | void;
751
754
  /* Excluded from this release type: handleWriteError */
752
755
  abstract addToOperationsList(batchType: BatchType, document: Document | UpdateStatement | DeleteStatement): this;
753
756
  }
@@ -860,7 +863,7 @@ export declare class CancellationToken extends TypedEventEmitter<{
860
863
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
861
864
  * @public
862
865
  */
863
- export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents> {
866
+ export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents<TSchema>> {
864
867
  pipeline: Document[];
865
868
  options: ChangeStreamOptions;
866
869
  parent: MongoClient | Db | Collection;
@@ -901,7 +904,8 @@ export declare class ChangeStream<TSchema extends Document = Document> extends T
901
904
  The cached resume token that is used to resume after the most recently returned change. */
902
905
  readonly resumeToken: ResumeToken;
903
906
  /** Check if there is any document still available in the Change Stream */
904
- hasNext(callback?: Callback): Promise<void> | void;
907
+ hasNext(): Promise<boolean>;
908
+ hasNext(callback: Callback<boolean>): void;
905
909
  /** Get the next available document from the Change Stream. */
906
910
  next(): Promise<ChangeStreamDocument<TSchema>>;
907
911
  next(callback: Callback<ChangeStreamDocument<TSchema>>): void;
@@ -974,14 +978,14 @@ export declare interface ChangeStreamDocument<TSchema extends Document = Documen
974
978
  fullDocument?: TSchema;
975
979
  }
976
980
  /** @public */
977
- export declare type ChangeStreamEvents = {
981
+ export declare type ChangeStreamEvents<TSchema extends Document = Document> = {
978
982
  resumeTokenChanged(token: ResumeToken): void;
979
- init(response: Document): void;
980
- more(response?: Document | undefined): void;
983
+ init(response: TSchema): void;
984
+ more(response?: TSchema | undefined): void;
981
985
  response(): void;
982
986
  end(): void;
983
987
  error(error: Error): void;
984
- change(change: ChangeStreamDocument): void;
988
+ change(change: ChangeStreamDocument<TSchema>): void;
985
989
  } & AbstractCursorEvents;
986
990
  /**
987
991
  * Options that can be passed to a ChangeStream. Note that startAfter, resumeAfter, and startAtOperationTime are all mutually exclusive, and the server will error if more than one is specified.
@@ -1312,10 +1316,10 @@ export declare class Collection<TSchema extends Document = Document> {
1312
1316
  * @param options - Optional settings for the command
1313
1317
  * @param callback - An optional callback, a Promise will be returned if none is provided
1314
1318
  */
1315
- replaceOne(filter: Filter<TSchema>, replacement: TSchema): Promise<UpdateResult | Document>;
1316
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, callback: Callback<UpdateResult | Document>): void;
1317
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, options: ReplaceOptions): Promise<UpdateResult | Document>;
1318
- replaceOne(filter: Filter<TSchema>, replacement: TSchema, options: ReplaceOptions, callback: Callback<UpdateResult | Document>): void;
1319
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<UpdateResult | Document>;
1320
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<UpdateResult | Document>): void;
1321
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions): Promise<UpdateResult | Document>;
1322
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions, callback: Callback<UpdateResult | Document>): void;
1319
1323
  /**
1320
1324
  * Update multiple documents in a collection
1321
1325
  *
@@ -1381,12 +1385,12 @@ export declare class Collection<TSchema extends Document = Document> {
1381
1385
  * @param options - Optional settings for the command
1382
1386
  * @param callback - An optional callback, a Promise will be returned if none is provided
1383
1387
  */
1384
- findOne(): Promise<TSchema | null>;
1385
- findOne(callback: Callback<TSchema | null>): void;
1386
- findOne(filter: Filter<TSchema>): Promise<TSchema | null>;
1387
- findOne(filter: Filter<TSchema>, callback: Callback<TSchema | null>): void;
1388
- findOne(filter: Filter<TSchema>, options: FindOptions): Promise<TSchema | null>;
1389
- findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<TSchema | null>): void;
1388
+ findOne(): Promise<WithId<TSchema> | null>;
1389
+ findOne(callback: Callback<WithId<TSchema> | null>): void;
1390
+ findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
1391
+ findOne(filter: Filter<TSchema>, callback: Callback<WithId<TSchema> | null>): void;
1392
+ findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
1393
+ findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<WithId<TSchema> | null>): void;
1390
1394
  findOne<T = TSchema>(): Promise<T | null>;
1391
1395
  findOne<T = TSchema>(callback: Callback<T | null>): void;
1392
1396
  findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
@@ -1397,8 +1401,8 @@ export declare class Collection<TSchema extends Document = Document> {
1397
1401
  *
1398
1402
  * @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
1399
1403
  */
1400
- find(): FindCursor<TSchema>;
1401
- find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
1404
+ find(): FindCursor<WithId<TSchema>>;
1405
+ find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
1402
1406
  find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
1403
1407
  /**
1404
1408
  * Returns the options of the collection.
@@ -1639,10 +1643,10 @@ export declare class Collection<TSchema extends Document = Document> {
1639
1643
  * @param options - Optional settings for the command
1640
1644
  * @param callback - An optional callback, a Promise will be returned if none is provided
1641
1645
  */
1642
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document): Promise<ModifyResult<TSchema>>;
1643
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, callback: Callback<ModifyResult<TSchema>>): void;
1644
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, options: FindOneAndReplaceOptions): Promise<ModifyResult<TSchema>>;
1645
- findOneAndReplace(filter: Filter<TSchema>, replacement: Document, options: FindOneAndReplaceOptions, callback: Callback<ModifyResult<TSchema>>): void;
1646
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<ModifyResult<TSchema>>;
1647
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
1648
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions): Promise<ModifyResult<TSchema>>;
1649
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions, callback: Callback<ModifyResult<TSchema>>): void;
1646
1650
  /**
1647
1651
  * Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
1648
1652
  *
@@ -1673,6 +1677,7 @@ export declare class Collection<TSchema extends Document = Document> {
1673
1677
  /**
1674
1678
  * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
1675
1679
  *
1680
+ * @deprecated collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.
1676
1681
  * @param map - The mapping function.
1677
1682
  * @param reduce - The reduce function.
1678
1683
  * @param options - Optional settings for the command
@@ -2225,10 +2230,9 @@ export declare class Db {
2225
2230
  * @param options - Optional settings for the command
2226
2231
  * @param callback - An optional callback, a Promise will be returned if none is provided
2227
2232
  */
2228
- createCollection<TSchema extends Document = Document>(name: string): Promise<Collection<TSchema>>;
2233
+ createCollection<TSchema extends Document = Document>(name: string, options?: CreateCollectionOptions): Promise<Collection<TSchema>>;
2229
2234
  createCollection<TSchema extends Document = Document>(name: string, callback: Callback<Collection<TSchema>>): void;
2230
- createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions): Promise<Collection<TSchema>>;
2231
- createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions, callback: Callback<Collection<TSchema>>): void;
2235
+ createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions | undefined, callback: Callback<Collection<TSchema>>): void;
2232
2236
  /**
2233
2237
  * Execute a command
2234
2238
  *
@@ -2579,8 +2583,8 @@ export declare type ExplainVerbosity = string;
2579
2583
  export declare type ExplainVerbosityLike = ExplainVerbosity | boolean;
2580
2584
  /** A MongoDB filter can be some portion of the schema or a set of operators @public */
2581
2585
  export declare type Filter<TSchema> = {
2582
- [P in keyof TSchema]?: Condition<TSchema[P]>;
2583
- } & RootFilterOperators<TSchema>;
2586
+ [P in keyof WithId<TSchema>]?: Condition<WithId<TSchema>[P]>;
2587
+ } & RootFilterOperators<WithId<TSchema>>;
2584
2588
  /** @public */
2585
2589
  export declare type FilterOperations<T> = T extends Record<string, any> ? {
2586
2590
  [key in keyof T]?: FilterOperators<T[key]>;
@@ -3181,11 +3185,13 @@ export declare class HostAddress {
3181
3185
  socketPath: string | undefined;
3182
3186
  isIPv6: boolean | undefined;
3183
3187
  constructor(hostString: string);
3188
+ inspect(): string;
3184
3189
  /**
3185
3190
  * @param ipv6Brackets - optionally request ipv6 bracket notation required for connection strings
3186
3191
  */
3187
3192
  toString(ipv6Brackets?: boolean): string;
3188
3193
  static fromString(s: string): HostAddress;
3194
+ static fromSrvRecord({ name, port }: SrvRecord): HostAddress;
3189
3195
  }
3190
3196
  /** @public */
3191
3197
  export declare interface IndexDescription extends Pick<CreateIndexesOptions, 'background' | 'unique' | 'partialFilterExpression' | 'sparse' | 'hidden' | 'expireAfterSeconds' | 'storageEngine' | 'version' | 'weights' | 'default_language' | 'language_override' | 'textIndexVersion' | '2dsphereIndexVersion' | 'bits' | 'min' | 'max' | 'bucketSize' | 'wildcardProjection'> {
@@ -3366,6 +3372,8 @@ export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name'
3366
3372
  export declare interface ListCollectionsOptions extends CommandOperationOptions {
3367
3373
  /** Since 4.0: If true, will only return the collection name in the response, and will omit additional info */
3368
3374
  nameOnly?: boolean;
3375
+ /** Since 4.0: If true and nameOnly is true, allows a user without the required privilege (i.e. listCollections action on the database) to run the command when access control is enforced. */
3376
+ authorizedCollections?: boolean;
3369
3377
  /** The batchSize for the returned command cursor or if pre 2.8 the systems batch collection */
3370
3378
  batchSize?: number;
3371
3379
  }
@@ -3778,6 +3786,16 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
3778
3786
  compressors?: CompressorName[] | string;
3779
3787
  /** An integer that specifies the compression level if using zlib for network compression. */
3780
3788
  zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
3789
+ /** The maximum number of hosts to connect to when using an srv connection string, a setting of `0` means unlimited hosts */
3790
+ srvMaxHosts?: number;
3791
+ /**
3792
+ * Modifies the srv URI to look like:
3793
+ *
3794
+ * `_{srvServiceName}._tcp.{hostname}.{domainname}`
3795
+ *
3796
+ * Querying this DNS URI is expected to respond with SRV records
3797
+ */
3798
+ srvServiceName?: string;
3781
3799
  /** The maximum number of connections in the connection pool. */
3782
3800
  maxPoolSize?: number;
3783
3801
  /** The minimum number of connections in the connection pool. */
@@ -4136,7 +4154,7 @@ export declare class MongoNotConnectedError extends MongoAPIError {
4136
4154
  * Mongo Client Options
4137
4155
  * @public
4138
4156
  */
4139
- export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
4157
+ export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'srvMaxHosts' | 'srvServiceName' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
4140
4158
  hosts: HostAddress[];
4141
4159
  srvHost?: string;
4142
4160
  credentials?: MongoCredentials;
@@ -4321,6 +4339,8 @@ export declare interface OperationOptions extends BSONSerializeOptions {
4321
4339
  willRetryWrites?: boolean;
4322
4340
  /** The preferred read preference (ReadPreference.primary, ReadPreference.primary_preferred, ReadPreference.secondary, ReadPreference.secondary_preferred, ReadPreference.nearest). */
4323
4341
  readPreference?: ReadPreferenceLike;
4342
+ /* Excluded from this release type: bypassPinningCheck */
4343
+ omitReadPreference?: boolean;
4324
4344
  }
4325
4345
  /* Excluded from this release type: OperationParent */
4326
4346
  /**
@@ -4341,11 +4361,13 @@ export declare type OperationTime = Timestamp;
4341
4361
  * `TSchema['_id'] extends ObjectId` which translated to "Is the _id property ObjectId?"
4342
4362
  * we instead ask "Does ObjectId look like (have the same shape) as the _id?"
4343
4363
  */
4344
- export declare type OptionalId<TSchema extends {
4364
+ export declare type OptionalId<TSchema> = TSchema extends {
4345
4365
  _id?: any;
4346
- }> = ObjectId extends TSchema['_id'] ? EnhancedOmit<TSchema, '_id'> & {
4366
+ } ? ObjectId extends TSchema['_id'] ? EnhancedOmit<TSchema, '_id'> & {
4367
+ _id?: InferIdType<TSchema>;
4368
+ } : WithId<TSchema> : EnhancedOmit<TSchema, '_id'> & {
4347
4369
  _id?: InferIdType<TSchema>;
4348
- } : WithId<TSchema>;
4370
+ };
4349
4371
  /** @public */
4350
4372
  export declare class OrderedBulkOperation extends BulkOperationBase {
4351
4373
  constructor(collection: Collection, options: BulkWriteOptions);
@@ -4573,7 +4595,7 @@ export declare interface ReplaceOneModel<TSchema extends Document = Document> {
4573
4595
  /** The filter to limit the replaced document. */
4574
4596
  filter: Filter<TSchema>;
4575
4597
  /** The document with which to replace the matched document. */
4576
- replacement: TSchema;
4598
+ replacement: WithoutId<TSchema>;
4577
4599
  /** Specifies a collation. */
4578
4600
  collation?: CollationOptions;
4579
4601
  /** The index to use. If specified, then the query system will only consider plans using the hinted index. */
@@ -4936,7 +4958,7 @@ export declare type TagSet = {
4936
4958
  export declare interface TimeSeriesCollectionOptions extends Document {
4937
4959
  timeField: string;
4938
4960
  metaField?: string;
4939
- granularity?: string;
4961
+ granularity?: 'seconds' | 'minutes' | 'hours' | string;
4940
4962
  }
4941
4963
  export { Timestamp };
4942
4964
  /* Excluded from this release type: Topology */
@@ -5025,6 +5047,8 @@ export declare class TopologyOpeningEvent {
5025
5047
  }
5026
5048
  /** @public */
5027
5049
  export declare interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
5050
+ srvMaxHosts: number;
5051
+ srvServiceName: string;
5028
5052
  hosts: HostAddress[];
5029
5053
  retryWrites: boolean;
5030
5054
  retryReads: boolean;
@@ -5088,7 +5112,7 @@ export declare class Transaction {
5088
5112
  */
5089
5113
  export declare interface TransactionOptions extends CommandOperationOptions {
5090
5114
  /** A default read concern for commands in this transaction */
5091
- readConcern?: ReadConcern;
5115
+ readConcern?: ReadConcernLike;
5092
5116
  /** A default writeConcern for commands in this transaction */
5093
5117
  writeConcern?: WriteConcern;
5094
5118
  /** A default read preference for commands in this transaction */