mongodb 4.1.4 → 4.3.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 (267) hide show
  1. package/README.md +16 -15
  2. package/lib/admin.js +3 -3
  3. package/lib/admin.js.map +1 -1
  4. package/lib/bson.js +16 -14
  5. package/lib/bson.js.map +1 -1
  6. package/lib/bulk/common.js +3 -4
  7. package/lib/bulk/common.js.map +1 -1
  8. package/lib/bulk/ordered.js +1 -1
  9. package/lib/bulk/ordered.js.map +1 -1
  10. package/lib/bulk/unordered.js +1 -1
  11. package/lib/bulk/unordered.js.map +1 -1
  12. package/lib/change_stream.js +6 -7
  13. package/lib/change_stream.js.map +1 -1
  14. package/lib/cmap/auth/auth_provider.js.map +1 -1
  15. package/lib/cmap/auth/gssapi.js +3 -3
  16. package/lib/cmap/auth/gssapi.js.map +1 -1
  17. package/lib/cmap/auth/mongo_credentials.js +16 -18
  18. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  19. package/lib/cmap/auth/mongocr.js +2 -2
  20. package/lib/cmap/auth/mongocr.js.map +1 -1
  21. package/lib/cmap/auth/mongodb_aws.js +6 -6
  22. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  23. package/lib/cmap/auth/plain.js +1 -1
  24. package/lib/cmap/auth/plain.js.map +1 -1
  25. package/lib/cmap/auth/providers.js +21 -0
  26. package/lib/cmap/auth/providers.js.map +1 -0
  27. package/lib/cmap/auth/scram.js +4 -4
  28. package/lib/cmap/auth/scram.js.map +1 -1
  29. package/lib/cmap/auth/x509.js +1 -1
  30. package/lib/cmap/auth/x509.js.map +1 -1
  31. package/lib/cmap/command_monitoring_events.js +1 -1
  32. package/lib/cmap/command_monitoring_events.js.map +1 -1
  33. package/lib/cmap/commands.js +20 -11
  34. package/lib/cmap/commands.js.map +1 -1
  35. package/lib/cmap/connect.js +102 -15
  36. package/lib/cmap/connect.js.map +1 -1
  37. package/lib/cmap/connection.js +27 -26
  38. package/lib/cmap/connection.js.map +1 -1
  39. package/lib/cmap/connection_pool.js +19 -30
  40. package/lib/cmap/connection_pool.js.map +1 -1
  41. package/lib/cmap/message_stream.js +3 -3
  42. package/lib/cmap/message_stream.js.map +1 -1
  43. package/lib/cmap/stream_description.js +4 -4
  44. package/lib/cmap/stream_description.js.map +1 -1
  45. package/lib/cmap/wire_protocol/compression.js.map +1 -1
  46. package/lib/cmap/wire_protocol/constants.js +4 -4
  47. package/lib/cmap/wire_protocol/shared.js +4 -3
  48. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  49. package/lib/collection.js +46 -47
  50. package/lib/collection.js.map +1 -1
  51. package/lib/connection_string.js +106 -49
  52. package/lib/connection_string.js.map +1 -1
  53. package/lib/constants.js +108 -1
  54. package/lib/constants.js.map +1 -1
  55. package/lib/cursor/abstract_cursor.js +10 -7
  56. package/lib/cursor/abstract_cursor.js.map +1 -1
  57. package/lib/cursor/aggregation_cursor.js +1 -1
  58. package/lib/cursor/aggregation_cursor.js.map +1 -1
  59. package/lib/cursor/find_cursor.js +1 -1
  60. package/lib/cursor/find_cursor.js.map +1 -1
  61. package/lib/db.js +23 -13
  62. package/lib/db.js.map +1 -1
  63. package/lib/deps.js +0 -1
  64. package/lib/deps.js.map +1 -1
  65. package/lib/encrypter.js +12 -4
  66. package/lib/encrypter.js.map +1 -1
  67. package/lib/error.js +47 -24
  68. package/lib/error.js.map +1 -1
  69. package/lib/gridfs/download.js +1 -1
  70. package/lib/gridfs/download.js.map +1 -1
  71. package/lib/gridfs/index.js +3 -3
  72. package/lib/gridfs/index.js.map +1 -1
  73. package/lib/gridfs/upload.js +3 -2
  74. package/lib/gridfs/upload.js.map +1 -1
  75. package/lib/index.js +81 -81
  76. package/lib/index.js.map +1 -1
  77. package/lib/logger.js +1 -1
  78. package/lib/logger.js.map +1 -1
  79. package/lib/mongo_client.js +5 -5
  80. package/lib/mongo_client.js.map +1 -1
  81. package/lib/mongo_types.js.map +1 -1
  82. package/lib/operations/add_user.js +2 -2
  83. package/lib/operations/add_user.js.map +1 -1
  84. package/lib/operations/aggregate.js +2 -3
  85. package/lib/operations/aggregate.js.map +1 -1
  86. package/lib/operations/bulk_write.js.map +1 -1
  87. package/lib/operations/collections.js +1 -1
  88. package/lib/operations/collections.js.map +1 -1
  89. package/lib/operations/command.js +9 -6
  90. package/lib/operations/command.js.map +1 -1
  91. package/lib/operations/common_functions.js.map +1 -1
  92. package/lib/operations/connect.js +4 -13
  93. package/lib/operations/connect.js.map +1 -1
  94. package/lib/operations/count.js +1 -1
  95. package/lib/operations/count.js.map +1 -1
  96. package/lib/operations/count_documents.js.map +1 -1
  97. package/lib/operations/create_collection.js +3 -2
  98. package/lib/operations/create_collection.js.map +1 -1
  99. package/lib/operations/delete.js +3 -3
  100. package/lib/operations/delete.js.map +1 -1
  101. package/lib/operations/distinct.js +3 -3
  102. package/lib/operations/distinct.js.map +1 -1
  103. package/lib/operations/drop.js +1 -1
  104. package/lib/operations/drop.js.map +1 -1
  105. package/lib/operations/estimated_document_count.js +2 -2
  106. package/lib/operations/estimated_document_count.js.map +1 -1
  107. package/lib/operations/eval.js +2 -2
  108. package/lib/operations/eval.js.map +1 -1
  109. package/lib/operations/execute_operation.js +23 -7
  110. package/lib/operations/execute_operation.js.map +1 -1
  111. package/lib/operations/find.js +5 -5
  112. package/lib/operations/find.js.map +1 -1
  113. package/lib/operations/find_and_modify.js +2 -2
  114. package/lib/operations/find_and_modify.js.map +1 -1
  115. package/lib/operations/get_more.js +28 -0
  116. package/lib/operations/get_more.js.map +1 -0
  117. package/lib/operations/indexes.js +4 -4
  118. package/lib/operations/indexes.js.map +1 -1
  119. package/lib/operations/insert.js +3 -3
  120. package/lib/operations/insert.js.map +1 -1
  121. package/lib/operations/is_capped.js +1 -1
  122. package/lib/operations/is_capped.js.map +1 -1
  123. package/lib/operations/list_collections.js +11 -6
  124. package/lib/operations/list_collections.js.map +1 -1
  125. package/lib/operations/list_databases.js +1 -1
  126. package/lib/operations/list_databases.js.map +1 -1
  127. package/lib/operations/map_reduce.js +4 -3
  128. package/lib/operations/map_reduce.js.map +1 -1
  129. package/lib/operations/operation.js +4 -2
  130. package/lib/operations/operation.js.map +1 -1
  131. package/lib/operations/options_operation.js +1 -1
  132. package/lib/operations/options_operation.js.map +1 -1
  133. package/lib/operations/profiling_level.js +1 -1
  134. package/lib/operations/profiling_level.js.map +1 -1
  135. package/lib/operations/remove_user.js +1 -1
  136. package/lib/operations/remove_user.js.map +1 -1
  137. package/lib/operations/rename.js +3 -3
  138. package/lib/operations/rename.js.map +1 -1
  139. package/lib/operations/run_command.js +1 -1
  140. package/lib/operations/run_command.js.map +1 -1
  141. package/lib/operations/set_profiling_level.js +2 -2
  142. package/lib/operations/set_profiling_level.js.map +1 -1
  143. package/lib/operations/stats.js +1 -1
  144. package/lib/operations/stats.js.map +1 -1
  145. package/lib/operations/update.js +2 -2
  146. package/lib/operations/update.js.map +1 -1
  147. package/lib/operations/validate_collection.js +1 -1
  148. package/lib/operations/validate_collection.js.map +1 -1
  149. package/lib/read_preference.js +15 -5
  150. package/lib/read_preference.js.map +1 -1
  151. package/lib/sdam/monitor.js +4 -4
  152. package/lib/sdam/monitor.js.map +1 -1
  153. package/lib/sdam/server.js +31 -31
  154. package/lib/sdam/server.js.map +1 -1
  155. package/lib/sdam/server_description.js +1 -1
  156. package/lib/sdam/server_description.js.map +1 -1
  157. package/lib/sdam/server_selection.js +38 -3
  158. package/lib/sdam/server_selection.js.map +1 -1
  159. package/lib/sdam/srv_polling.js +11 -11
  160. package/lib/sdam/srv_polling.js.map +1 -1
  161. package/lib/sdam/topology.js +40 -62
  162. package/lib/sdam/topology.js.map +1 -1
  163. package/lib/sdam/topology_description.js +36 -14
  164. package/lib/sdam/topology_description.js.map +1 -1
  165. package/lib/sessions.js +13 -28
  166. package/lib/sessions.js.map +1 -1
  167. package/lib/transactions.js +1 -1
  168. package/lib/transactions.js.map +1 -1
  169. package/lib/utils.js +90 -23
  170. package/lib/utils.js.map +1 -1
  171. package/mongodb.d.ts +159 -65
  172. package/mongodb.ts34.d.ts +184 -65
  173. package/package.json +26 -24
  174. package/src/admin.ts +9 -9
  175. package/src/bson.ts +26 -17
  176. package/src/bulk/common.ts +26 -20
  177. package/src/bulk/ordered.ts +4 -4
  178. package/src/bulk/unordered.ts +5 -5
  179. package/src/change_stream.ts +35 -32
  180. package/src/cmap/auth/auth_provider.ts +3 -3
  181. package/src/cmap/auth/gssapi.ts +8 -8
  182. package/src/cmap/auth/mongo_credentials.ts +2 -6
  183. package/src/cmap/auth/mongocr.ts +3 -2
  184. package/src/cmap/auth/mongodb_aws.ts +10 -11
  185. package/src/cmap/auth/plain.ts +1 -1
  186. package/src/cmap/auth/providers.ts +21 -0
  187. package/src/cmap/auth/scram.ts +9 -9
  188. package/src/cmap/auth/x509.ts +3 -3
  189. package/src/cmap/command_monitoring_events.ts +2 -2
  190. package/src/cmap/commands.ts +30 -19
  191. package/src/cmap/connect.ts +142 -22
  192. package/src/cmap/connection.ts +73 -52
  193. package/src/cmap/connection_pool.ts +39 -39
  194. package/src/cmap/connection_pool_events.ts +1 -1
  195. package/src/cmap/message_stream.ts +9 -8
  196. package/src/cmap/stream_description.ts +5 -5
  197. package/src/cmap/wire_protocol/compression.ts +2 -2
  198. package/src/cmap/wire_protocol/constants.ts +4 -4
  199. package/src/cmap/wire_protocol/shared.ts +10 -9
  200. package/src/collection.ts +133 -106
  201. package/src/connection_string.ts +141 -60
  202. package/src/constants.ts +116 -0
  203. package/src/cursor/abstract_cursor.ts +21 -22
  204. package/src/cursor/aggregation_cursor.ts +6 -6
  205. package/src/cursor/find_cursor.ts +2 -2
  206. package/src/db.ts +49 -39
  207. package/src/deps.ts +3 -1
  208. package/src/encrypter.ts +12 -3
  209. package/src/error.ts +52 -24
  210. package/src/gridfs/download.ts +10 -8
  211. package/src/gridfs/index.ts +11 -11
  212. package/src/gridfs/upload.ts +13 -10
  213. package/src/index.ts +204 -199
  214. package/src/logger.ts +2 -1
  215. package/src/mongo_client.ts +58 -32
  216. package/src/mongo_types.ts +98 -20
  217. package/src/operations/add_user.ts +6 -5
  218. package/src/operations/aggregate.ts +6 -7
  219. package/src/operations/bulk_write.ts +5 -5
  220. package/src/operations/collections.ts +2 -2
  221. package/src/operations/command.ts +19 -8
  222. package/src/operations/common_functions.ts +4 -4
  223. package/src/operations/connect.ts +4 -14
  224. package/src/operations/count.ts +4 -4
  225. package/src/operations/count_documents.ts +3 -3
  226. package/src/operations/create_collection.ts +8 -7
  227. package/src/operations/delete.ts +5 -5
  228. package/src/operations/distinct.ts +4 -4
  229. package/src/operations/drop.ts +4 -4
  230. package/src/operations/estimated_document_count.ts +5 -5
  231. package/src/operations/eval.ts +5 -5
  232. package/src/operations/execute_operation.ts +30 -11
  233. package/src/operations/find.ts +14 -14
  234. package/src/operations/find_and_modify.ts +7 -7
  235. package/src/operations/get_more.ts +49 -0
  236. package/src/operations/indexes.ts +16 -16
  237. package/src/operations/insert.ts +9 -9
  238. package/src/operations/is_capped.ts +3 -3
  239. package/src/operations/list_collections.ts +18 -10
  240. package/src/operations/list_databases.ts +4 -4
  241. package/src/operations/map_reduce.ts +10 -9
  242. package/src/operations/operation.ts +8 -4
  243. package/src/operations/options_operation.ts +3 -3
  244. package/src/operations/profiling_level.ts +4 -4
  245. package/src/operations/remove_user.ts +4 -4
  246. package/src/operations/rename.ts +6 -6
  247. package/src/operations/run_command.ts +3 -3
  248. package/src/operations/set_profiling_level.ts +6 -5
  249. package/src/operations/stats.ts +4 -4
  250. package/src/operations/update.ts +10 -10
  251. package/src/operations/validate_collection.ts +4 -4
  252. package/src/read_preference.ts +18 -7
  253. package/src/sdam/common.ts +2 -2
  254. package/src/sdam/events.ts +1 -1
  255. package/src/sdam/monitor.ts +13 -14
  256. package/src/sdam/server.ts +71 -61
  257. package/src/sdam/server_description.ts +4 -4
  258. package/src/sdam/server_selection.ts +46 -3
  259. package/src/sdam/srv_polling.ts +15 -13
  260. package/src/sdam/topology.ts +89 -90
  261. package/src/sdam/topology_description.ts +39 -15
  262. package/src/sessions.ts +31 -48
  263. package/src/transactions.ts +6 -6
  264. package/src/utils.ts +123 -43
  265. package/lib/cmap/auth/defaultAuthProviders.js +0 -30
  266. package/lib/cmap/auth/defaultAuthProviders.js.map +0 -1
  267. package/src/cmap/auth/defaultAuthProviders.ts +0 -32
package/mongodb.ts34.d.ts CHANGED
@@ -21,10 +21,12 @@ import { Map as Map_2 } from 'bson';
21
21
  import { MaxKey } from 'bson';
22
22
  import { MinKey } from 'bson';
23
23
  import { ObjectId } from 'bson';
24
+ import { ObjectIdLike } from 'bson';
24
25
  import { Readable } from 'stream';
25
26
  import { serialize as serialize_2 } from 'bson';
26
27
  import { SerializeOptions } from 'bson';
27
28
  import { Socket } from 'net';
29
+ import { SrvRecord } from 'dns';
28
30
  import { TcpNetConnectOpts } from 'net';
29
31
  import { Timestamp } from 'bson';
30
32
  import { TLSSocket } from 'tls';
@@ -616,6 +618,7 @@ export declare interface AutoEncryptionOptions {
616
618
  /** Command line arguments to use when auto-spawning a mongocryptd */
617
619
  mongocryptdSpawnArgs?: string[];
618
620
  };
621
+ proxyOptions?: ProxyOptions;
619
622
  }
620
623
  /**
621
624
  * Keeps the state of a unordered batch so we can rewrite the results
@@ -649,9 +652,11 @@ export { BSONRegExp };
649
652
  * BSON Serialization options.
650
653
  * @public
651
654
  */
652
- export declare interface BSONSerializeOptions extends Pick<SerializeOptions, Exclude<keyof SerializeOptions, 'index'>>, Pick<DeserializeOptions, Exclude<keyof DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index'>> {
655
+ export declare interface BSONSerializeOptions extends Pick<SerializeOptions, Exclude<keyof SerializeOptions, 'index'>>, Pick<DeserializeOptions, Exclude<keyof DeserializeOptions, 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index' | 'validation'>> {
653
656
  /** Return BSON filled buffers from operations */
654
657
  raw?: boolean;
658
+ /** Enable utf8 validation when deserializing BSON documents. Defaults to true. */
659
+ enableUtf8Validation?: boolean;
655
660
  }
656
661
  export { BSONSymbol };
657
662
  /** @public */
@@ -746,8 +751,10 @@ export declare abstract class BulkOperationBase {
746
751
  readonly bsonOptions: BSONSerializeOptions;
747
752
  readonly writeConcern: WriteConcern | undefined;
748
753
  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;
754
+ execute(options?: BulkWriteOptions): Promise<BulkWriteResult>;
755
+ execute(callback: Callback<BulkWriteResult>): void;
756
+ execute(options: BulkWriteOptions | undefined, callback: Callback<BulkWriteResult>): void;
757
+ execute(options?: BulkWriteOptions | Callback<BulkWriteResult>, callback?: Callback<BulkWriteResult>): Promise<BulkWriteResult> | void;
751
758
  /* Excluded from this release type: handleWriteError */
752
759
  abstract addToOperationsList(batchType: BatchType, document: Document | UpdateStatement | DeleteStatement): this;
753
760
  }
@@ -860,7 +867,7 @@ export declare class CancellationToken extends TypedEventEmitter<{
860
867
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
861
868
  * @public
862
869
  */
863
- export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents> {
870
+ export declare class ChangeStream<TSchema extends Document = Document> extends TypedEventEmitter<ChangeStreamEvents<TSchema>> {
864
871
  pipeline: Document[];
865
872
  options: ChangeStreamOptions;
866
873
  parent: MongoClient | Db | Collection;
@@ -901,7 +908,8 @@ export declare class ChangeStream<TSchema extends Document = Document> extends T
901
908
  The cached resume token that is used to resume after the most recently returned change. */
902
909
  readonly resumeToken: ResumeToken;
903
910
  /** Check if there is any document still available in the Change Stream */
904
- hasNext(callback?: Callback): Promise<void> | void;
911
+ hasNext(): Promise<boolean>;
912
+ hasNext(callback: Callback<boolean>): void;
905
913
  /** Get the next available document from the Change Stream. */
906
914
  next(): Promise<ChangeStreamDocument<TSchema>>;
907
915
  next(callback: Callback<ChangeStreamDocument<TSchema>>): void;
@@ -974,14 +982,14 @@ export declare interface ChangeStreamDocument<TSchema extends Document = Documen
974
982
  fullDocument?: TSchema;
975
983
  }
976
984
  /** @public */
977
- export declare type ChangeStreamEvents = {
985
+ export declare type ChangeStreamEvents<TSchema extends Document = Document> = {
978
986
  resumeTokenChanged(token: ResumeToken): void;
979
- init(response: Document): void;
980
- more(response?: Document | undefined): void;
987
+ init(response: TSchema): void;
988
+ more(response?: TSchema | undefined): void;
981
989
  response(): void;
982
990
  end(): void;
983
991
  error(error: Error): void;
984
- change(change: ChangeStreamDocument): void;
992
+ change(change: ChangeStreamDocument<TSchema>): void;
985
993
  } & AbstractCursorEvents;
986
994
  /**
987
995
  * 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.
@@ -1240,10 +1248,10 @@ export declare class Collection<TSchema extends Document = Document> {
1240
1248
  * @param options - Optional settings for the command
1241
1249
  * @param callback - An optional callback, a Promise will be returned if none is provided
1242
1250
  */
1243
- insertOne(doc: OptionalId<TSchema>): Promise<InsertOneResult<TSchema>>;
1244
- insertOne(doc: OptionalId<TSchema>, callback: Callback<InsertOneResult<TSchema>>): void;
1245
- insertOne(doc: OptionalId<TSchema>, options: InsertOneOptions): Promise<InsertOneResult<TSchema>>;
1246
- insertOne(doc: OptionalId<TSchema>, options: InsertOneOptions, callback: Callback<InsertOneResult<TSchema>>): void;
1251
+ insertOne(doc: OptionalUnlessRequiredId<TSchema>): Promise<InsertOneResult<TSchema>>;
1252
+ insertOne(doc: OptionalUnlessRequiredId<TSchema>, callback: Callback<InsertOneResult<TSchema>>): void;
1253
+ insertOne(doc: OptionalUnlessRequiredId<TSchema>, options: InsertOneOptions): Promise<InsertOneResult<TSchema>>;
1254
+ insertOne(doc: OptionalUnlessRequiredId<TSchema>, options: InsertOneOptions, callback: Callback<InsertOneResult<TSchema>>): void;
1247
1255
  /**
1248
1256
  * Inserts an array of documents into MongoDB. If documents passed in do not contain the **_id** field,
1249
1257
  * one will be added to each of the documents missing it by the driver, mutating the document. This behavior
@@ -1253,10 +1261,10 @@ export declare class Collection<TSchema extends Document = Document> {
1253
1261
  * @param options - Optional settings for the command
1254
1262
  * @param callback - An optional callback, a Promise will be returned if none is provided
1255
1263
  */
1256
- insertMany(docs: OptionalId<TSchema>[]): Promise<InsertManyResult<TSchema>>;
1257
- insertMany(docs: OptionalId<TSchema>[], callback: Callback<InsertManyResult<TSchema>>): void;
1258
- insertMany(docs: OptionalId<TSchema>[], options: BulkWriteOptions): Promise<InsertManyResult<TSchema>>;
1259
- insertMany(docs: OptionalId<TSchema>[], options: BulkWriteOptions, callback: Callback<InsertManyResult<TSchema>>): void;
1264
+ insertMany(docs: OptionalUnlessRequiredId<TSchema>[]): Promise<InsertManyResult<TSchema>>;
1265
+ insertMany(docs: OptionalUnlessRequiredId<TSchema>[], callback: Callback<InsertManyResult<TSchema>>): void;
1266
+ insertMany(docs: OptionalUnlessRequiredId<TSchema>[], options: BulkWriteOptions): Promise<InsertManyResult<TSchema>>;
1267
+ insertMany(docs: OptionalUnlessRequiredId<TSchema>[], options: BulkWriteOptions, callback: Callback<InsertManyResult<TSchema>>): void;
1260
1268
  /**
1261
1269
  * Perform a bulkWrite operation without a fluent API
1262
1270
  *
@@ -1312,10 +1320,10 @@ export declare class Collection<TSchema extends Document = Document> {
1312
1320
  * @param options - Optional settings for the command
1313
1321
  * @param callback - An optional callback, a Promise will be returned if none is provided
1314
1322
  */
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;
1323
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<UpdateResult | Document>;
1324
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<UpdateResult | Document>): void;
1325
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions): Promise<UpdateResult | Document>;
1326
+ replaceOne(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: ReplaceOptions, callback: Callback<UpdateResult | Document>): void;
1319
1327
  /**
1320
1328
  * Update multiple documents in a collection
1321
1329
  *
@@ -1381,12 +1389,12 @@ export declare class Collection<TSchema extends Document = Document> {
1381
1389
  * @param options - Optional settings for the command
1382
1390
  * @param callback - An optional callback, a Promise will be returned if none is provided
1383
1391
  */
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;
1392
+ findOne(): Promise<WithId<TSchema> | null>;
1393
+ findOne(callback: Callback<WithId<TSchema> | null>): void;
1394
+ findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
1395
+ findOne(filter: Filter<TSchema>, callback: Callback<WithId<TSchema> | null>): void;
1396
+ findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
1397
+ findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<WithId<TSchema> | null>): void;
1390
1398
  findOne<T = TSchema>(): Promise<T | null>;
1391
1399
  findOne<T = TSchema>(callback: Callback<T | null>): void;
1392
1400
  findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
@@ -1397,8 +1405,8 @@ export declare class Collection<TSchema extends Document = Document> {
1397
1405
  *
1398
1406
  * @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
1399
1407
  */
1400
- find(): FindCursor<TSchema>;
1401
- find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
1408
+ find(): FindCursor<WithId<TSchema>>;
1409
+ find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
1402
1410
  find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
1403
1411
  /**
1404
1412
  * Returns the options of the collection.
@@ -1639,10 +1647,10 @@ export declare class Collection<TSchema extends Document = Document> {
1639
1647
  * @param options - Optional settings for the command
1640
1648
  * @param callback - An optional callback, a Promise will be returned if none is provided
1641
1649
  */
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;
1650
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>): Promise<ModifyResult<TSchema>>;
1651
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
1652
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions): Promise<ModifyResult<TSchema>>;
1653
+ findOneAndReplace(filter: Filter<TSchema>, replacement: WithoutId<TSchema>, options: FindOneAndReplaceOptions, callback: Callback<ModifyResult<TSchema>>): void;
1646
1654
  /**
1647
1655
  * Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
1648
1656
  *
@@ -1673,6 +1681,7 @@ export declare class Collection<TSchema extends Document = Document> {
1673
1681
  /**
1674
1682
  * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
1675
1683
  *
1684
+ * @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
1685
  * @param map - The mapping function.
1677
1686
  * @param reduce - The reduce function.
1678
1687
  * @param options - Optional settings for the command
@@ -1699,7 +1708,7 @@ export declare class Collection<TSchema extends Document = Document> {
1699
1708
  * @param options - Optional settings for the command
1700
1709
  * @param callback - An optional callback, a Promise will be returned if none is provided
1701
1710
  */
1702
- insert(docs: OptionalId<TSchema>[], options: BulkWriteOptions, callback: Callback<InsertManyResult<TSchema>>): Promise<InsertManyResult<TSchema>> | void;
1711
+ insert(docs: OptionalUnlessRequiredId<TSchema>[], options: BulkWriteOptions, callback: Callback<InsertManyResult<TSchema>>): Promise<InsertManyResult<TSchema>> | void;
1703
1712
  /**
1704
1713
  * Updates documents.
1705
1714
  *
@@ -1752,6 +1761,9 @@ export declare interface CollectionInfo extends Document {
1752
1761
  }
1753
1762
  /** @public */
1754
1763
  export declare interface CollectionOptions extends BSONSerializeOptions, WriteConcernOptions, LoggerOptions {
1764
+ /**
1765
+ * @deprecated Use readPreference instead
1766
+ */
1755
1767
  slaveOk?: boolean;
1756
1768
  /** Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) */
1757
1769
  readConcern?: ReadConcernLike;
@@ -1966,7 +1978,7 @@ export declare type ConnectionEvents = {
1966
1978
  unpinned(pinType: string): void;
1967
1979
  };
1968
1980
  /** @public */
1969
- export declare interface ConnectionOptions extends SupportedNodeConnectionOptions, StreamDescriptionOptions {
1981
+ export declare interface ConnectionOptions extends SupportedNodeConnectionOptions, StreamDescriptionOptions, ProxyOptions {
1970
1982
  id: number | '<monitor>';
1971
1983
  generation: number;
1972
1984
  hostAddress: HostAddress;
@@ -2207,7 +2219,15 @@ export declare class Db {
2207
2219
  constructor(client: MongoClient, databaseName: string, options?: DbOptions);
2208
2220
  readonly databaseName: string;
2209
2221
  readonly options: DbOptions | undefined;
2222
+ /*
2223
+ * slaveOk specified
2224
+ * @deprecated Use secondaryOk instead
2225
+ */
2210
2226
  readonly slaveOk: boolean;
2227
+ /*
2228
+ * Check if a secondary can be used (because the read preference is *not* set to primary)
2229
+ */
2230
+ readonly secondaryOk: boolean;
2211
2231
  readonly readConcern: ReadConcern | undefined;
2212
2232
  /*
2213
2233
  * The current readPreference of the Db. If not explicitly defined for
@@ -2225,10 +2245,9 @@ export declare class Db {
2225
2245
  * @param options - Optional settings for the command
2226
2246
  * @param callback - An optional callback, a Promise will be returned if none is provided
2227
2247
  */
2228
- createCollection<TSchema extends Document = Document>(name: string): Promise<Collection<TSchema>>;
2248
+ createCollection<TSchema extends Document = Document>(name: string, options?: CreateCollectionOptions): Promise<Collection<TSchema>>;
2229
2249
  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;
2250
+ createCollection<TSchema extends Document = Document>(name: string, options: CreateCollectionOptions | undefined, callback: Callback<Collection<TSchema>>): void;
2232
2251
  /**
2233
2252
  * Execute a command
2234
2253
  *
@@ -2579,14 +2598,14 @@ export declare type ExplainVerbosity = string;
2579
2598
  export declare type ExplainVerbosityLike = ExplainVerbosity | boolean;
2580
2599
  /** A MongoDB filter can be some portion of the schema or a set of operators @public */
2581
2600
  export declare type Filter<TSchema> = {
2582
- [P in keyof TSchema]?: Condition<TSchema[P]>;
2583
- } & RootFilterOperators<TSchema>;
2601
+ [Property in Join<NestedPaths<WithId<TSchema>>, '.'>]?: Condition<PropertyType<WithId<TSchema>, Property>>;
2602
+ } & RootFilterOperators<WithId<TSchema>>;
2584
2603
  /** @public */
2585
2604
  export declare type FilterOperations<T> = T extends Record<string, any> ? {
2586
2605
  [key in keyof T]?: FilterOperators<T[key]>;
2587
2606
  } : FilterOperators<T>;
2588
2607
  /** @public */
2589
- export declare interface FilterOperators<TValue> extends Document {
2608
+ export declare interface FilterOperators<TValue> extends NonObjectIdLikeDocument {
2590
2609
  $eq?: TValue;
2591
2610
  $gt?: TValue;
2592
2611
  $gte?: TValue;
@@ -2872,7 +2891,7 @@ export declare interface FindOptions<TSchema extends Document = Document> extend
2872
2891
  timeout?: boolean;
2873
2892
  /** Specify if the cursor is tailable. */
2874
2893
  tailable?: boolean;
2875
- /** Specify if the cursor is a a tailable-await cursor. Requires `tailable` to be true */
2894
+ /** Specify if the cursor is a tailable-await cursor. Requires `tailable` to be true */
2876
2895
  awaitData?: boolean;
2877
2896
  /** Set the batchSize for the getMoreCommand when iterating over the query results. */
2878
2897
  batchSize?: number;
@@ -3129,12 +3148,12 @@ export declare class GridFSBucketWriteStream extends Writable implements NodeJS.
3129
3148
  * @param encoding - Optional encoding for the buffer
3130
3149
  * @param callback - Function to call when all files and chunks have been persisted to MongoDB
3131
3150
  */
3132
- end(): void;
3133
- end(chunk: Buffer): void;
3134
- end(callback: Callback<GridFSFile | void>): void;
3135
- end(chunk: Buffer, callback: Callback<GridFSFile | void>): void;
3136
- end(chunk: Buffer, encoding: BufferEncoding): void;
3137
- end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): void;
3151
+ end(): this;
3152
+ end(chunk: Buffer): this;
3153
+ end(callback: Callback<GridFSFile | void>): this;
3154
+ end(chunk: Buffer, callback: Callback<GridFSFile | void>): this;
3155
+ end(chunk: Buffer, encoding: BufferEncoding): this;
3156
+ end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): this;
3138
3157
  }
3139
3158
  /** @public */
3140
3159
  export declare interface GridFSBucketWriteStreamOptions extends WriteConcernOptions {
@@ -3181,11 +3200,14 @@ export declare class HostAddress {
3181
3200
  socketPath: string | undefined;
3182
3201
  isIPv6: boolean | undefined;
3183
3202
  constructor(hostString: string);
3203
+ inspect(): string;
3184
3204
  /**
3185
3205
  * @param ipv6Brackets - optionally request ipv6 bracket notation required for connection strings
3186
3206
  */
3187
3207
  toString(ipv6Brackets?: boolean): string;
3188
3208
  static fromString(s: string): HostAddress;
3209
+ static fromHostPort(host: string, port: number): HostAddress;
3210
+ static fromSrvRecord({ name, port }: SrvRecord): HostAddress;
3189
3211
  }
3190
3212
  /** @public */
3191
3213
  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'> {
@@ -3216,7 +3238,9 @@ export declare type IndexSpecification = OneOrMore<string | [
3216
3238
  /** Given an object shaped type, return the type of the _id field or default to ObjectId @public */
3217
3239
  export declare type InferIdType<TSchema> = TSchema extends {
3218
3240
  _id: infer IdType;
3219
- } ? {} extends IdType ? Exclude<IdType, {}> : unknown extends IdType ? ObjectId : IdType : ObjectId;
3241
+ } ? Record<any, never> extends IdType ? never : IdType : TSchema extends {
3242
+ _id?: infer IdType;
3243
+ } ? unknown extends IdType ? ObjectId : IdType : ObjectId;
3220
3244
  /** @public */
3221
3245
  export declare interface InsertManyResult<TSchema = Document> {
3222
3246
  /** Indicates whether this write result was acknowledged. If not, then all other members of this result will be undefined */
@@ -3254,6 +3278,17 @@ export declare type IntegerType = number | Int32 | Long;
3254
3278
  /* Excluded from this release type: InterruptibleAsyncInterval */
3255
3279
  /** @public */
3256
3280
  export declare type IsAny<Type, ResultIfAny, ResultIfNotAny> = true extends false & Type ? ResultIfAny : ResultIfNotAny;
3281
+ /**
3282
+ * Helper types for dot-notation filter attributes
3283
+ */
3284
+ /** @public */
3285
+ export declare type Join<T extends unknown[], D extends string> = T extends [
3286
+ ] ? '' : T extends [
3287
+ string | number
3288
+ ] ? `${T[0]}` : T extends [
3289
+ string | number,
3290
+ ...infer R
3291
+ ] ? `${T[0]}${D}${Join<R, D>}` : string;
3257
3292
  /* Excluded from this release type: kBeforeHandshake */
3258
3293
  /* Excluded from this release type: kBuffer */
3259
3294
  /* Excluded from this release type: kBuffers */
@@ -3366,6 +3401,8 @@ export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name'
3366
3401
  export declare interface ListCollectionsOptions extends CommandOperationOptions {
3367
3402
  /** Since 4.0: If true, will only return the collection name in the response, and will omit additional info */
3368
3403
  nameOnly?: boolean;
3404
+ /** 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. */
3405
+ authorizedCollections?: boolean;
3369
3406
  /** The batchSize for the returned command cursor or if pre 2.8 the systems batch collection */
3370
3407
  batchSize?: number;
3371
3408
  }
@@ -3552,7 +3589,21 @@ export declare const MONGO_CLIENT_EVENTS: readonly [
3552
3589
  "connectionCheckedOut",
3553
3590
  "connectionCheckedIn",
3554
3591
  "connectionPoolCleared",
3555
- ...("error" | "close" | "commandStarted" | "commandSucceeded" | "commandFailed" | "serverHeartbeatStarted" | "serverHeartbeatSucceeded" | "serverHeartbeatFailed" | "timeout" | "serverOpening" | "serverClosed" | "serverDescriptionChanged" | "topologyOpening" | "topologyClosed" | "topologyDescriptionChanged")[]
3592
+ "commandStarted",
3593
+ "commandSucceeded",
3594
+ "commandFailed",
3595
+ "serverOpening",
3596
+ "serverClosed",
3597
+ "serverDescriptionChanged",
3598
+ "topologyOpening",
3599
+ "topologyClosed",
3600
+ "topologyDescriptionChanged",
3601
+ "error",
3602
+ "timeout",
3603
+ "close",
3604
+ "serverHeartbeatStarted",
3605
+ "serverHeartbeatSucceeded",
3606
+ "serverHeartbeatFailed"
3556
3607
  ];
3557
3608
  /**
3558
3609
  * An error generated when the driver API is used incorrectly
@@ -3683,8 +3734,8 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> {
3683
3734
  *
3684
3735
  * @see docs.mongodb.org/manual/reference/connection-string/
3685
3736
  */
3686
- connect(): Promise<MongoClient>;
3687
- connect(callback: Callback<MongoClient>): void;
3737
+ connect(): Promise<this>;
3738
+ connect(callback: Callback<this>): void;
3688
3739
  /**
3689
3740
  * Close the db and its underlying connections
3690
3741
  *
@@ -3778,6 +3829,16 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
3778
3829
  compressors?: CompressorName[] | string;
3779
3830
  /** An integer that specifies the compression level if using zlib for network compression. */
3780
3831
  zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
3832
+ /** The maximum number of hosts to connect to when using an srv connection string, a setting of `0` means unlimited hosts */
3833
+ srvMaxHosts?: number;
3834
+ /**
3835
+ * Modifies the srv URI to look like:
3836
+ *
3837
+ * `_{srvServiceName}._tcp.{hostname}.{domainname}`
3838
+ *
3839
+ * Querying this DNS URI is expected to respond with SRV records
3840
+ */
3841
+ srvServiceName?: string;
3781
3842
  /** The maximum number of connections in the connection pool. */
3782
3843
  maxPoolSize?: number;
3783
3844
  /** The minimum number of connections in the connection pool. */
@@ -3880,6 +3941,14 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
3880
3941
  autoEncryption?: AutoEncryptionOptions;
3881
3942
  /** Allows a wrapping driver to amend the client metadata generated by the driver to include information about the wrapping driver */
3882
3943
  driverInfo?: DriverInfo;
3944
+ /** Configures a Socks5 proxy host used for creating TCP connections. */
3945
+ proxyHost?: string;
3946
+ /** Configures a Socks5 proxy port used for creating TCP connections. */
3947
+ proxyPort?: number;
3948
+ /** Configures a Socks5 proxy username when the proxy in proxyHost requires username/password authentication. */
3949
+ proxyUsername?: string;
3950
+ /** Configures a Socks5 proxy password when the proxy in proxyHost requires username/password authentication. */
3951
+ proxyPassword?: string;
3883
3952
  }
3884
3953
  /* Excluded from this release type: MongoClientPrivate */
3885
3954
  /**
@@ -4136,7 +4205,7 @@ export declare class MongoNotConnectedError extends MongoAPIError {
4136
4205
  * Mongo Client Options
4137
4206
  * @public
4138
4207
  */
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 {
4208
+ 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
4209
  hosts: HostAddress[];
4141
4210
  srvHost?: string;
4142
4211
  credentials?: MongoCredentials;
@@ -4149,6 +4218,10 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
4149
4218
  dbName: string;
4150
4219
  metadata: ClientMetadata;
4151
4220
  autoEncrypter?: AutoEncrypter;
4221
+ proxyHost?: string;
4222
+ proxyPort?: number;
4223
+ proxyUsername?: string;
4224
+ proxyPassword?: string;
4152
4225
  /* Excluded from this release type: connectionType */
4153
4226
  /* Excluded from this release type: encrypter */
4154
4227
  /* Excluded from this release type: userSpecifiedAuthSource */
@@ -4297,6 +4370,29 @@ export declare interface MonitorOptions extends Pick<ConnectionOptions, Exclude<
4297
4370
  }
4298
4371
  /* Excluded from this release type: MonitorPrivate */
4299
4372
  /* Excluded from this release type: Msg */
4373
+ /** @public */
4374
+ export declare type NestedPaths<Type> = Type extends string | number | boolean | Date | RegExp | Buffer | Uint8Array | ((...args: any[]) => any) | {
4375
+ _bsontype: string;
4376
+ } ? [
4377
+ ] : Type extends ReadonlyArray<infer ArrayType> ? [
4378
+ number,
4379
+ ...NestedPaths<ArrayType>
4380
+ ] : Type extends Map<string, any> ? [
4381
+ string
4382
+ ] : Type extends object ? {
4383
+ [Key in Extract<keyof Type, string>]: [
4384
+ Key,
4385
+ ...NestedPaths<Type[Key]>
4386
+ ];
4387
+ }[Extract<keyof Type, string>] : [
4388
+ ];
4389
+ /**
4390
+ * @public
4391
+ * A type that extends Document but forbids anything that "looks like" an object id.
4392
+ */
4393
+ export declare type NonObjectIdLikeDocument = {
4394
+ [key in keyof ObjectIdLike]?: never;
4395
+ } & Document;
4300
4396
  /** It avoids using fields with not acceptable types @public */
4301
4397
  export declare type NotAcceptedFields<TSchema, FieldType> = {
4302
4398
  readonly [key in KeysOfOtherType<TSchema, FieldType>]?: never;
@@ -4321,6 +4417,8 @@ export declare interface OperationOptions extends BSONSerializeOptions {
4321
4417
  willRetryWrites?: boolean;
4322
4418
  /** The preferred read preference (ReadPreference.primary, ReadPreference.primary_preferred, ReadPreference.secondary, ReadPreference.secondary_preferred, ReadPreference.nearest). */
4323
4419
  readPreference?: ReadPreferenceLike;
4420
+ /* Excluded from this release type: bypassPinningCheck */
4421
+ omitReadPreference?: boolean;
4324
4422
  }
4325
4423
  /* Excluded from this release type: OperationParent */
4326
4424
  /**
@@ -4335,19 +4433,24 @@ export declare type OperationTime = Timestamp;
4335
4433
  /**
4336
4434
  * Add an optional _id field to an object shaped type
4337
4435
  * @public
4436
+ */
4437
+ export declare type OptionalId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
4438
+ _id?: InferIdType<TSchema>;
4439
+ };
4440
+ /**
4441
+ * Adds an optional _id field to an object shaped type, unless the _id field is requried on that type.
4442
+ * In the case _id is required, this method continues to require_id.
4443
+ *
4444
+ * @public
4338
4445
  *
4339
4446
  * @privateRemarks
4340
4447
  * `ObjectId extends TSchema['_id']` is a confusing ordering at first glance. Rather than ask
4341
4448
  * `TSchema['_id'] extends ObjectId` which translated to "Is the _id property ObjectId?"
4342
4449
  * we instead ask "Does ObjectId look like (have the same shape) as the _id?"
4343
4450
  */
4344
- export declare type OptionalId<TSchema> = TSchema extends {
4345
- _id?: any;
4346
- } ? ObjectId extends TSchema['_id'] ? EnhancedOmit<TSchema, '_id'> & {
4347
- _id?: InferIdType<TSchema>;
4348
- } : WithId<TSchema> : EnhancedOmit<TSchema, '_id'> & {
4349
- _id?: InferIdType<TSchema>;
4350
- };
4451
+ export declare type OptionalUnlessRequiredId<TSchema> = TSchema extends {
4452
+ _id: any;
4453
+ } ? TSchema : OptionalId<TSchema>;
4351
4454
  /** @public */
4352
4455
  export declare class OrderedBulkOperation extends BulkOperationBase {
4353
4456
  constructor(collection: Collection, options: BulkWriteOptions);
@@ -4396,6 +4499,15 @@ declare class Promise_2 {
4396
4499
  }
4397
4500
  export { Promise_2 as Promise };
4398
4501
  /** @public */
4502
+ export declare type PropertyType<Type, Property extends string> = string extends Property ? unknown : Property extends keyof Type ? Type[Property] : Property extends `${number}` ? Type extends ReadonlyArray<infer ArrayType> ? ArrayType : unknown : Property extends `${infer Key}.${infer Rest}` ? Key extends `${number}` ? Type extends ReadonlyArray<infer ArrayType> ? PropertyType<ArrayType, Rest> : unknown : Key extends keyof Type ? Type[Key] extends Map<string, infer MapType> ? MapType : PropertyType<Type[Key], Rest> : unknown : unknown;
4503
+ /** @public */
4504
+ export declare interface ProxyOptions {
4505
+ proxyHost?: string;
4506
+ proxyPort?: number;
4507
+ proxyUsername?: string;
4508
+ proxyPassword?: string;
4509
+ }
4510
+ /** @public */
4399
4511
  export declare type PullAllOperator<TSchema> = ({
4400
4512
  readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
4401
4513
  } & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
@@ -4509,11 +4621,16 @@ export declare class ReadPreference {
4509
4621
  */
4510
4622
  isValid(mode?: string): boolean;
4511
4623
  /**
4512
- * Indicates that this readPreference needs the "slaveOk" bit when sent over the wire
4513
- *
4624
+ * Indicates that this readPreference needs the "secondaryOk" bit when sent over the wire
4625
+ * @deprecated Use secondaryOk instead
4514
4626
  * @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query
4515
4627
  */
4516
4628
  slaveOk(): boolean;
4629
+ /**
4630
+ * Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire
4631
+ * @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query
4632
+ */
4633
+ secondaryOk(): boolean;
4517
4634
  /**
4518
4635
  * Check if the two ReadPreferences are equivalent
4519
4636
  *
@@ -4575,7 +4692,7 @@ export declare interface ReplaceOneModel<TSchema extends Document = Document> {
4575
4692
  /** The filter to limit the replaced document. */
4576
4693
  filter: Filter<TSchema>;
4577
4694
  /** The document with which to replace the matched document. */
4578
- replacement: TSchema;
4695
+ replacement: WithoutId<TSchema>;
4579
4696
  /** Specifies a collation. */
4580
4697
  collation?: CollationOptions;
4581
4698
  /** The index to use. If specified, then the query system will only consider plans using the hinted index. */
@@ -4938,7 +5055,7 @@ export declare type TagSet = {
4938
5055
  export declare interface TimeSeriesCollectionOptions extends Document {
4939
5056
  timeField: string;
4940
5057
  metaField?: string;
4941
- granularity?: string;
5058
+ granularity?: 'seconds' | 'minutes' | 'hours' | string;
4942
5059
  }
4943
5060
  export { Timestamp };
4944
5061
  /* Excluded from this release type: Topology */
@@ -5027,6 +5144,8 @@ export declare class TopologyOpeningEvent {
5027
5144
  }
5028
5145
  /** @public */
5029
5146
  export declare interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
5147
+ srvMaxHosts: number;
5148
+ srvServiceName: string;
5030
5149
  hosts: HostAddress[];
5031
5150
  retryWrites: boolean;
5032
5151
  retryReads: boolean;
@@ -5090,7 +5209,7 @@ export declare class Transaction {
5090
5209
  */
5091
5210
  export declare interface TransactionOptions extends CommandOperationOptions {
5092
5211
  /** A default read concern for commands in this transaction */
5093
- readConcern?: ReadConcern;
5212
+ readConcern?: ReadConcernLike;
5094
5213
  /** A default writeConcern for commands in this transaction */
5095
5214
  writeConcern?: WriteConcern;
5096
5215
  /** A default read preference for commands in this transaction */