@nullix/zod-mongoose-studio 1.0.13 → 2.1.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 (268) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/builds/latest.json +1 -1
  3. package/.output/public/_nuxt/builds/meta/8b851c04-1848-472a-b5cd-0727aaaf90f4.json +1 -0
  4. package/.output/server/chunks/nitro/nitro.mjs +232 -232
  5. package/.output/server/chunks/routes/api/parse.post.mjs +54 -11
  6. package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
  7. package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
  8. package/.output/server/node_modules/bson/package.json +9 -11
  9. package/.output/server/node_modules/kareem/index.js +228 -343
  10. package/.output/server/node_modules/kareem/package.json +3 -3
  11. package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
  12. package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
  13. package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
  14. package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
  15. package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
  16. package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
  17. package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  18. package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
  19. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  20. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
  21. package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
  22. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
  23. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
  24. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
  25. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
  26. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
  27. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
  28. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
  29. package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
  30. package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
  31. package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
  32. package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
  33. package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
  34. package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
  35. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
  36. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
  37. package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
  38. package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
  39. package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
  40. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
  41. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
  42. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
  43. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
  44. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
  45. package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
  46. package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
  47. package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
  48. package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
  49. package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
  50. package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
  51. package/.output/server/node_modules/mongodb/lib/db.js +6 -7
  52. package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
  53. package/.output/server/node_modules/mongodb/lib/error.js +7 -10
  54. package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
  55. package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
  56. package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
  57. package/.output/server/node_modules/mongodb/lib/index.js +2 -4
  58. package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
  59. package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
  60. package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
  61. package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
  62. package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
  63. package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
  64. package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
  65. package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  66. package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
  67. package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
  68. package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
  69. package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  70. package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
  71. package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
  72. package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
  73. package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
  74. package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
  75. package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
  76. package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
  77. package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
  78. package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
  79. package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
  80. package/.output/server/node_modules/mongodb/package.json +49 -45
  81. package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
  82. package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
  83. package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
  84. package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
  85. package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
  86. package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
  87. package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
  88. package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
  89. package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
  90. package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
  91. package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
  92. package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
  93. package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
  94. package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
  95. package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
  96. package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
  97. package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
  98. package/.output/server/node_modules/mongoose/lib/document.js +712 -531
  99. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
  100. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
  101. package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
  102. package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
  103. package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
  104. package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
  105. package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
  106. package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
  107. package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
  108. package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
  109. package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
  110. package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
  111. package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
  112. package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
  113. package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
  114. package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
  115. package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
  116. package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
  117. package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
  118. package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  119. package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  120. package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
  121. package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
  122. package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
  123. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
  124. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  125. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  126. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
  127. package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
  128. package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
  129. package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
  130. package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
  131. package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
  132. package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
  133. package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  134. package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  135. package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
  136. package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  137. package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
  138. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
  139. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  140. package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
  141. package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
  142. package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
  143. package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
  144. package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
  145. package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  146. package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
  147. package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
  148. package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
  149. package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
  150. package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
  151. package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
  152. package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
  153. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
  154. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
  155. package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
  156. package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
  157. package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
  158. package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  159. package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
  160. package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  161. package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
  162. package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
  163. package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
  164. package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
  165. package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
  166. package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
  167. package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
  168. package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
  169. package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
  170. package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
  171. package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
  172. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
  173. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
  174. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
  175. package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
  176. package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
  177. package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
  178. package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
  179. package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
  180. package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
  181. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  182. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
  183. package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
  184. package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
  185. package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
  186. package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
  187. package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
  188. package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
  189. package/.output/server/node_modules/mongoose/lib/model.js +940 -946
  190. package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
  191. package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
  192. package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
  193. package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
  194. package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
  195. package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
  196. package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
  197. package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
  198. package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
  199. package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
  200. package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
  201. package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
  202. package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
  203. package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
  204. package/.output/server/node_modules/mongoose/lib/query.js +700 -548
  205. package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
  206. package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
  207. package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
  208. package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
  209. package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
  210. package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
  211. package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
  212. package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
  213. package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
  214. package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
  215. package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
  216. package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
  217. package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
  218. package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
  219. package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
  220. package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
  221. package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
  222. package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
  223. package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
  224. package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
  225. package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
  226. package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
  227. package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
  228. package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
  229. package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
  230. package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
  231. package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
  232. package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
  233. package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
  234. package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
  235. package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
  236. package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
  237. package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
  238. package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
  239. package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
  240. package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
  241. package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
  242. package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
  243. package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
  244. package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
  245. package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
  246. package/.output/server/node_modules/mongoose/package.json +46 -63
  247. package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
  248. package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
  249. package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
  250. package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
  251. package/.output/server/node_modules/mquery/package.json +4 -7
  252. package/.output/server/package.json +7 -9
  253. package/package.json +3 -3
  254. package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
  255. package/.output/server/node_modules/debug/package.json +0 -64
  256. package/.output/server/node_modules/debug/src/browser.js +0 -272
  257. package/.output/server/node_modules/debug/src/common.js +0 -292
  258. package/.output/server/node_modules/debug/src/index.js +0 -10
  259. package/.output/server/node_modules/debug/src/node.js +0 -263
  260. package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
  261. package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
  262. package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
  263. package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
  264. package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
  265. package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
  266. package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
  267. package/.output/server/node_modules/supports-color/index.js +0 -202
  268. package/.output/server/node_modules/supports-color/package.json +0 -64
@@ -132,7 +132,7 @@ Object.defineProperty(Connection.prototype, 'readyState', {
132
132
  },
133
133
  set: function(val) {
134
134
  if (!(val in STATES)) {
135
- throw new Error('Invalid connection state: ' + val);
135
+ throw new MongooseError('Invalid connection state: ' + val);
136
136
  }
137
137
 
138
138
  if (this._readyState !== val) {
@@ -158,7 +158,7 @@ Object.defineProperty(Connection.prototype, 'readyState', {
158
158
  *
159
159
  * conn.get('test'); // returns the 'test' value
160
160
  *
161
- * @param {String} key
161
+ * @param {string} key
162
162
  * @method get
163
163
  * @api public
164
164
  */
@@ -177,7 +177,7 @@ Connection.prototype.get = function getOption(key) {
177
177
  * Supported options include:
178
178
  *
179
179
  * - `maxTimeMS`: Set [`maxTimeMS`](https://mongoosejs.com/docs/api/query.html#Query.prototype.maxTimeMS()) for all queries on this connection.
180
- * - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arugments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
180
+ * - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arguments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
181
181
  *
182
182
  * #### Example:
183
183
  *
@@ -185,8 +185,8 @@ Connection.prototype.get = function getOption(key) {
185
185
  * conn.get('test'); // 'foo'
186
186
  * conn.options.test; // 'foo'
187
187
  *
188
- * @param {String} key
189
- * @param {Any} val
188
+ * @param {string} key
189
+ * @param {any} val
190
190
  * @method set
191
191
  * @api public
192
192
  */
@@ -410,11 +410,11 @@ Connection.prototype.config;
410
410
  * with specified options. Used to create [capped collections](https://www.mongodb.com/docs/manual/core/capped-collections/)
411
411
  * and [views](https://www.mongodb.com/docs/manual/core/views/) from mongoose.
412
412
  *
413
- * Options are passed down without modification to the [MongoDB driver's `createCollection()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
413
+ * Options are passed down without modification to the [MongoDB driver's `createCollection()` function](https://mongodb.github.io/node-mongodb-native/7.0/classes/Db.html#createCollection)
414
414
  *
415
415
  * @method createCollection
416
416
  * @param {string} collection The collection to create
417
- * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
417
+ * @param {object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/7.0/classes/Db.html#createCollection)
418
418
  * @return {Promise}
419
419
  * @api public
420
420
  */
@@ -444,8 +444,8 @@ Connection.prototype.createCollection = async function createCollection(collecti
444
444
  *
445
445
  * @method bulkWrite
446
446
  * @param {Array} ops
447
- * @param {Object} [options]
448
- * @param {Boolean} [options.ordered] If false, perform unordered operations. If true, perform ordered operations.
447
+ * @param {object} [options]
448
+ * @param {boolean} [options.ordered] If false, perform unordered operations. If true, perform ordered operations.
449
449
  * @param {Session} [options.session] The session to use for the operation.
450
450
  * @return {Promise}
451
451
  * @see MongoDB https://www.mongodb.com/docs/manual/reference/command/bulkWrite/#mongodb-dbcommand-dbcmd.bulkWrite
@@ -606,7 +606,7 @@ Connection.prototype.bulkWrite = async function bulkWrite(ops, options) {
606
606
  * Calls `createCollection()` on a models in a series.
607
607
  *
608
608
  * @method createCollections
609
- * @param {Boolean} continueOnError When true, will continue to create collections and create a new error class for the collections that errored.
609
+ * @param {boolean} continueOnError When true, will continue to create collections and create a new error class for the collections that errored.
610
610
  * @returns {Promise}
611
611
  * @api public
612
612
  */
@@ -630,7 +630,7 @@ Connection.prototype.createCollections = async function createCollections(option
630
630
  }
631
631
  }
632
632
 
633
- if (!continueOnError && Object.keys(errorsMap).length) {
633
+ if (!continueOnError && utils.hasOwnKeys(errorsMap)) {
634
634
  const message = Object.entries(errorsMap).map(([modelName, err]) => `${modelName}: ${err.message}`).join(', ');
635
635
  const createCollectionsError = new CreateCollectionsError(message, errorsMap);
636
636
  throw createCollectionsError;
@@ -655,7 +655,7 @@ Connection.prototype.createCollections = async function createCollections(option
655
655
 
656
656
  Connection.prototype.withSession = async function withSession(executor) {
657
657
  if (arguments.length === 0) {
658
- throw new Error('Please provide an executor function');
658
+ throw new MongooseError('Please provide an executor function');
659
659
  }
660
660
  return await this.client.withSession(executor);
661
661
  };
@@ -678,8 +678,8 @@ Connection.prototype.withSession = async function withSession(executor) {
678
678
  *
679
679
  *
680
680
  * @method startSession
681
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
682
- * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
681
+ * @param {object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/7.0/classes/MongoClient.html#startSession)
682
+ * @param {boolean} [options.causalConsistency=true] set to false to disable causal consistency
683
683
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`
684
684
  * @api public
685
685
  */
@@ -701,7 +701,7 @@ Connection.prototype.startSession = async function startSession(options) {
701
701
  * async function executes successfully and attempt to retry if
702
702
  * there was a retriable error.
703
703
  *
704
- * Calls the MongoDB driver's [`session.withTransaction()`](https://mongodb.github.io/node-mongodb-native/4.9/classes/ClientSession.html#withTransaction),
704
+ * Calls the MongoDB driver's [`session.withTransaction()`](https://mongodb.github.io/node-mongodb-native/7.0/classes/ClientSession.html#withTransaction),
705
705
  * but also handles resetting Mongoose document state as shown below.
706
706
  *
707
707
  * #### Example:
@@ -713,7 +713,7 @@ Connection.prototype.startSession = async function startSession(options) {
713
713
  * doc.isNew; // false
714
714
  *
715
715
  * // Throw an error to abort the transaction
716
- * throw new Error('Oops!');
716
+ * throw new MongooseError('Oops!');
717
717
  * },{ readPreference: 'primary' }).catch(() => {});
718
718
  *
719
719
  * // true, `transaction()` reset the document's state because the
@@ -723,7 +723,7 @@ Connection.prototype.startSession = async function startSession(options) {
723
723
  * @method transaction
724
724
  * @param {Function} fn Function to execute in a transaction
725
725
  * @param {mongodb.TransactionOptions} [options] Optional settings for the transaction
726
- * @return {Promise<Any>} promise that is fulfilled if Mongoose successfully committed the transaction, or rejects if the transaction was aborted or if Mongoose failed to commit the transaction. If fulfilled, the promise resolves to a MongoDB command result.
726
+ * @return {Promise<any>} promise that is fulfilled if Mongoose successfully committed the transaction, or rejects if the transaction was aborted or if Mongoose failed to commit the transaction. If fulfilled, the promise resolves to a MongoDB command result.
727
727
  * @api public
728
728
  */
729
729
 
@@ -824,8 +824,8 @@ Connection.prototype.dropCollection = async function dropCollection(collection)
824
824
  /**
825
825
  * Waits for connection to be established, so the connection has a `client`
826
826
  *
827
- * @param {Boolean} [noTimeout=false] if set, don't put a timeout on the operation. Used internally so `mongoose.model()` doesn't leave open handles.
828
- * @return Promise
827
+ * @param {boolean} [noTimeout=false] if set, don't put a timeout on the operation. Used internally so `mongoose.model()` doesn't leave open handles.
828
+ * @return {Promise}
829
829
  * @api private
830
830
  */
831
831
 
@@ -883,7 +883,7 @@ Connection.prototype._getBufferTimeoutMS = function _getBufferTimeoutMS() {
883
883
  if (this.config.bufferTimeoutMS != null) {
884
884
  return this.config.bufferTimeoutMS;
885
885
  }
886
- if (this.base != null && this.base.get('bufferTimeoutMS') != null) {
886
+ if (this.base?.get('bufferTimeoutMS') != null) {
887
887
  return this.base.get('bufferTimeoutMS');
888
888
  }
889
889
  return 10000;
@@ -894,7 +894,7 @@ Connection.prototype._getBufferTimeoutMS = function _getBufferTimeoutMS() {
894
894
  * Returns an array of collection objects.
895
895
  *
896
896
  * @method listCollections
897
- * @return {Promise<Collection[]>}
897
+ * @return {Promise<Array<Collection>>}
898
898
  * @api public
899
899
  */
900
900
 
@@ -915,7 +915,7 @@ Connection.prototype.listCollections = async function listCollections() {
915
915
  * databases; // [{ name: 'mongoose_test', sizeOnDisk: 0, empty: false }]
916
916
  *
917
917
  * @method listCollections
918
- * @return {Promise<{ databases: Array<{ name: string }> }>}
918
+ * @return {Promise<Array<{ databases: { name: string } }>>}
919
919
  * @api public
920
920
  */
921
921
 
@@ -1005,10 +1005,7 @@ Connection.prototype.error = function error(err, callback) {
1005
1005
  Connection.prototype.onOpen = function() {
1006
1006
  this.readyState = STATES.connected;
1007
1007
 
1008
- for (const d of this._queue) {
1009
- d.fn.apply(d.ctx, d.args);
1010
- }
1011
- this._queue = [];
1008
+ this._flushQueue();
1012
1009
 
1013
1010
  // avoid having the collection subscribe to our event emitter
1014
1011
  // to prevent 0.3 warning
@@ -1021,25 +1018,39 @@ Connection.prototype.onOpen = function() {
1021
1018
  this.emit('open');
1022
1019
  };
1023
1020
 
1021
+ /**
1022
+ * Flush all buffered operations in `_queue`. Called by `onOpen()` and
1023
+ * by the heartbeat handler when a previously-stale connection recovers.
1024
+ *
1025
+ * @api private
1026
+ */
1027
+
1028
+ Connection.prototype._flushQueue = function _flushQueue() {
1029
+ const queue = this._queue;
1030
+ this._queue = [];
1031
+ for (const d of queue) {
1032
+ d.fn.apply(d.ctx, d.args);
1033
+ }
1034
+ };
1035
+
1024
1036
  /**
1025
1037
  * Opens the connection with a URI using `MongoClient.connect()`.
1026
1038
  *
1027
- * @param {String} uri The URI to connect with.
1028
- * @param {Object} [options] Passed on to [`MongoClient.connect`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#connect-1)
1029
- * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
1030
- * @param {Number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
1031
- * @param {String} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
1032
- * @param {String} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
1033
- * @param {String} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
1034
- * @param {Number} [options.maxPoolSize=100] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
1035
- * @param {Number} [options.minPoolSize=0] The minimum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
1036
- * @param {Number} [options.serverSelectionTimeoutMS] If `useUnifiedTopology = true`, the MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
1037
- * @param {Number} [options.heartbeatFrequencyMS] If `useUnifiedTopology = true`, the MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
1038
- * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
1039
- * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
1040
- * @param {Number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. `socketTimeoutMS` defaults to 0, which means Node.js will not time out the socket due to inactivity. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
1041
- * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
1042
- * @param {Boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
1039
+ * @param {string} uri The URI to connect with.
1040
+ * @param {object} [options] Passed on to [`MongoClient.connect`](https://mongodb.github.io/node-mongodb-native/7.0/classes/MongoClient.html#connect)
1041
+ * @param {boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
1042
+ * @param {number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
1043
+ * @param {string} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
1044
+ * @param {string} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
1045
+ * @param {string} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
1046
+ * @param {number} [options.maxPoolSize=100] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
1047
+ * @param {number} [options.minPoolSize=0] The minimum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
1048
+ * @param {number} [options.serverSelectionTimeoutMS] The MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
1049
+ * @param {number} [options.heartbeatFrequencyMS] The MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
1050
+ * @param {boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
1051
+ * @param {number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. `socketTimeoutMS` defaults to 0, which means Node.js will not time out the socket due to inactivity. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
1052
+ * @param {number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
1053
+ * @param {boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
1043
1054
  * @returns {Promise<Connection>}
1044
1055
  * @api public
1045
1056
  */
@@ -1106,7 +1117,7 @@ Connection.prototype.openUri = async function openUri(uri, options) {
1106
1117
  /**
1107
1118
  * Listen to events in the Connection
1108
1119
  *
1109
- * @param {String} event The event to listen on
1120
+ * @param {string} event The event to listen on
1110
1121
  * @param {Function} callback
1111
1122
  * @see Connection#readyState https://mongoosejs.com/docs/api/connection.html#Connection.prototype.readyState
1112
1123
  *
@@ -1128,7 +1139,7 @@ Connection.prototype.on = function on(event, callback) {
1128
1139
  /**
1129
1140
  * Listen to a event once in the Connection
1130
1141
  *
1131
- * @param {String} event The event to listen on
1142
+ * @param {string} event The event to listen on
1132
1143
  * @param {Function} callback
1133
1144
  * @see Connection#readyState https://mongoosejs.com/docs/api/connection.html#Connection.prototype.readyState
1134
1145
  *
@@ -1178,7 +1189,7 @@ function _handleConnectionErrors(err) {
1178
1189
  * but also removes the connection from Mongoose's `connections` list and prevents the
1179
1190
  * connection from ever being re-opened.
1180
1191
  *
1181
- * @param {Boolean} [force]
1192
+ * @param {boolean} [force]
1182
1193
  * @returns {Promise}
1183
1194
  */
1184
1195
 
@@ -1199,7 +1210,7 @@ Connection.prototype.destroy = async function destroy(force) {
1199
1210
  /**
1200
1211
  * Closes the connection
1201
1212
  *
1202
- * @param {Boolean} [force] optional
1213
+ * @param {boolean} [force] optional
1203
1214
  * @return {Promise}
1204
1215
  * @api public
1205
1216
  */
@@ -1232,8 +1243,8 @@ Connection.prototype.close = async function close(force) {
1232
1243
  /**
1233
1244
  * Handles closing the connection
1234
1245
  *
1235
- * @param {Boolean} force
1236
- * @param {Boolean} destroy
1246
+ * @param {boolean} force
1247
+ * @param {boolean} destroy
1237
1248
  * @returns {Connection} this
1238
1249
  * @api private
1239
1250
  */
@@ -1250,8 +1261,11 @@ Connection.prototype._close = async function _close(force, destroy) {
1250
1261
  const conn = this;
1251
1262
  switch (this.readyState) {
1252
1263
  case STATES.disconnected:
1253
- if (destroy && this.base.connections.indexOf(conn) !== -1) {
1254
- this.base.connections.splice(this.base.connections.indexOf(conn), 1);
1264
+ if (destroy) {
1265
+ const index = this.base.connections.indexOf(conn);
1266
+ if (index !== -1) {
1267
+ this.base.connections.splice(index, 1);
1268
+ }
1255
1269
  }
1256
1270
  if (!closeCalled) {
1257
1271
  await this.doClose(force);
@@ -1262,8 +1276,11 @@ Connection.prototype._close = async function _close(force, destroy) {
1262
1276
  case STATES.connected:
1263
1277
  this.readyState = STATES.disconnecting;
1264
1278
  await this.doClose(force);
1265
- if (destroy && _this.base.connections.indexOf(conn) !== -1) {
1266
- this.base.connections.splice(this.base.connections.indexOf(conn), 1);
1279
+ if (destroy) {
1280
+ const index = _this.base.connections.indexOf(conn);
1281
+ if (index !== -1) {
1282
+ this.base.connections.splice(index, 1);
1283
+ }
1267
1284
  }
1268
1285
  this.onClose(force);
1269
1286
 
@@ -1305,7 +1322,7 @@ Connection.prototype._close = async function _close(force, destroy) {
1305
1322
  */
1306
1323
 
1307
1324
  Connection.prototype.doClose = function doClose() {
1308
- throw new Error('Connection#doClose unimplemented by driver');
1325
+ throw new MongooseError('Connection#doClose unimplemented by driver');
1309
1326
  };
1310
1327
 
1311
1328
  /**
@@ -1341,21 +1358,21 @@ Connection.prototype.onClose = function onClose(force) {
1341
1358
  * Using a Collection bypasses Mongoose middleware, validation, and casting,
1342
1359
  * letting you use [MongoDB Node.js driver](https://mongodb.github.io/node-mongodb-native/) functionality directly.
1343
1360
  *
1344
- * @param {String} name of the collection
1345
- * @param {Object} [options] optional collection options
1361
+ * @param {string} name of the collection
1362
+ * @param {object} [options] optional collection options
1346
1363
  * @return {Collection} collection instance
1347
1364
  * @api public
1348
1365
  */
1349
1366
 
1350
1367
  Connection.prototype.collection = function(name, options) {
1351
1368
  const defaultOptions = {
1352
- autoIndex: this.config.autoIndex != null ? this.config.autoIndex : this.base.options.autoIndex,
1353
- autoCreate: this.config.autoCreate != null ? this.config.autoCreate : this.base.options.autoCreate,
1354
- autoSearchIndex: this.config.autoSearchIndex != null ? this.config.autoSearchIndex : this.base.options.autoSearchIndex
1369
+ autoIndex: this.config.autoIndex ?? this.base.options.autoIndex,
1370
+ autoCreate: this.config.autoCreate ?? this.base.options.autoCreate,
1371
+ autoSearchIndex: this.config.autoSearchIndex ?? this.base.options.autoSearchIndex
1355
1372
  };
1356
1373
  options = Object.assign({}, defaultOptions, options ? clone(options) : {});
1357
1374
  options.$wasForceClosed = this.$wasForceClosed;
1358
- const Collection = this.base && this.base.__driver && this.base.__driver.Collection || driver.get().Collection;
1375
+ const Collection = this.base?.__driver?.Collection || driver.get().Collection;
1359
1376
  if (!(name in this.collections)) {
1360
1377
  this.collections[name] = new Collection(name, this, options);
1361
1378
  }
@@ -1376,7 +1393,7 @@ Connection.prototype.collection = function(name, options) {
1376
1393
  * db.model('Test', new Schema({})); // Prints "Applied"
1377
1394
  *
1378
1395
  * @param {Function} fn plugin callback
1379
- * @param {Object} [opts] optional options
1396
+ * @param {object} [opts] optional options
1380
1397
  * @return {Connection} this
1381
1398
  * @see plugins https://mongoosejs.com/docs/plugins.html
1382
1399
  * @api public
@@ -1411,11 +1428,11 @@ Connection.prototype.plugin = function(fn, opts) {
1411
1428
  * const collectionName = 'actor'
1412
1429
  * const M = conn.model('Actor', schema, collectionName)
1413
1430
  *
1414
- * @param {String|Function} name the model name or class extending Model
1431
+ * @param {string|Function} name the model name or class extending Model
1415
1432
  * @param {Schema} [schema] a schema. necessary when defining a model
1416
- * @param {String} [collection] name of mongodb collection (optional) if not given it will be induced from model name
1417
- * @param {Object} [options]
1418
- * @param {Boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
1433
+ * @param {string} [collection] name of mongodb collection (optional) if not given it will be induced from model name
1434
+ * @param {object} [options]
1435
+ * @param {boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
1419
1436
  * @see Mongoose#model https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model()
1420
1437
  * @return {Model} The compiled model
1421
1438
  * @api public
@@ -1448,7 +1465,7 @@ Connection.prototype.model = function model(name, schema, collection, options) {
1448
1465
  }
1449
1466
  }
1450
1467
  if (schema && !schema.instanceOfSchema) {
1451
- throw new Error('The 2nd parameter to `mongoose.model()` should be a ' +
1468
+ throw new MongooseError('The 2nd parameter to `mongoose.model()` should be a ' +
1452
1469
  'schema or a POJO');
1453
1470
  }
1454
1471
 
@@ -1456,7 +1473,7 @@ Connection.prototype.model = function model(name, schema, collection, options) {
1456
1473
  const opts = Object.assign(defaultOptions, options, { connection: this });
1457
1474
  if (this.models[name] && !collection && opts.overwriteModels !== true) {
1458
1475
  // model exists but we are not subclassing with custom collection
1459
- if (schema && schema.instanceOfSchema && schema !== this.models[name].schema) {
1476
+ if (schema?.instanceOfSchema && schema !== this.models[name].schema) {
1460
1477
  throw new MongooseError.OverwriteModelError(name);
1461
1478
  }
1462
1479
  return this.models[name];
@@ -1464,7 +1481,7 @@ Connection.prototype.model = function model(name, schema, collection, options) {
1464
1481
 
1465
1482
  let model;
1466
1483
 
1467
- if (schema && schema.instanceOfSchema) {
1484
+ if (schema?.instanceOfSchema) {
1468
1485
  applyPlugins(schema, this.plugins, null, '$connectionPluginsApplied');
1469
1486
 
1470
1487
  // compile a model
@@ -1537,7 +1554,7 @@ Connection.prototype.model = function model(name, schema, collection, options) {
1537
1554
  * });
1538
1555
  *
1539
1556
  * @api public
1540
- * @param {String|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
1557
+ * @param {string|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
1541
1558
  * @return {Connection} this
1542
1559
  */
1543
1560
 
@@ -1561,7 +1578,7 @@ Connection.prototype.deleteModel = function deleteModel(name) {
1561
1578
  }
1562
1579
  }
1563
1580
  } else {
1564
- throw new Error('First parameter to `deleteModel()` must be a string ' +
1581
+ throw new MongooseError('First parameter to `deleteModel()` must be a string ' +
1565
1582
  'or regexp, got "' + name + '"');
1566
1583
  }
1567
1584
 
@@ -1593,27 +1610,14 @@ Connection.prototype.deleteModel = function deleteModel(name) {
1593
1610
  *
1594
1611
  * @api public
1595
1612
  * @param {Array} [pipeline]
1596
- * @param {Object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#watch)
1613
+ * @param {object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/7.0/classes/Db.html#watch)
1597
1614
  * @return {ChangeStream} mongoose-specific change stream wrapper, inherits from EventEmitter
1598
1615
  */
1599
1616
 
1600
1617
  Connection.prototype.watch = function watch(pipeline, options) {
1601
- const changeStreamThunk = cb => {
1602
- immediate(() => {
1603
- if (this.readyState === STATES.connecting) {
1604
- this.once('open', function() {
1605
- const driverChangeStream = this.db.watch(pipeline, options);
1606
- cb(null, driverChangeStream);
1607
- });
1608
- } else {
1609
- const driverChangeStream = this.db.watch(pipeline, options);
1610
- cb(null, driverChangeStream);
1611
- }
1612
- });
1613
- };
1618
+ const changeStreamPromise = this._waitForConnect().then(() => this.db.watch(pipeline, options));
1614
1619
 
1615
- const changeStream = new ChangeStream(changeStreamThunk, pipeline, options);
1616
- return changeStream;
1620
+ return new ChangeStream(changeStreamPromise, pipeline, options);
1617
1621
  };
1618
1622
 
1619
1623
  /**
@@ -1643,7 +1647,7 @@ Connection.prototype.asPromise = async function asPromise() {
1643
1647
  /**
1644
1648
  * Returns an array of model names created on this connection.
1645
1649
  * @api public
1646
- * @return {String[]}
1650
+ * @return {Array<string>}
1647
1651
  */
1648
1652
 
1649
1653
  Connection.prototype.modelNames = function modelNames() {
@@ -1656,7 +1660,7 @@ Connection.prototype.modelNames = function modelNames() {
1656
1660
  * password is not required.
1657
1661
  *
1658
1662
  * @api private
1659
- * @return {Boolean} true if the connection should be authenticated after it is opened, otherwise false.
1663
+ * @return {boolean} true if the connection should be authenticated after it is opened, otherwise false.
1660
1664
  */
1661
1665
  Connection.prototype.shouldAuthenticate = function shouldAuthenticate() {
1662
1666
  return this.user != null &&
@@ -1668,11 +1672,11 @@ Connection.prototype.shouldAuthenticate = function shouldAuthenticate() {
1668
1672
  * password to authenticate according to the auth objects passed into the openUri methods.
1669
1673
  *
1670
1674
  * @api private
1671
- * @return {Boolean} true if the authentication mechanism specified in the options object requires
1675
+ * @return {boolean} true if the authentication mechanism specified in the options object requires
1672
1676
  * a password, otherwise false.
1673
1677
  */
1674
1678
  Connection.prototype.authMechanismDoesNotRequirePassword = function authMechanismDoesNotRequirePassword() {
1675
- if (this.options && this.options.auth) {
1679
+ if (this.options?.auth) {
1676
1680
  return noPasswordAuthMechanisms.indexOf(this.options.auth.authMechanism) >= 0;
1677
1681
  }
1678
1682
  return true;
@@ -1684,9 +1688,9 @@ Connection.prototype.authMechanismDoesNotRequirePassword = function authMechanis
1684
1688
  * but in some authentication methods, a password is not required for authentication so only a username
1685
1689
  * is required.
1686
1690
  *
1687
- * @param {Object} [options] the options object passed into the openUri methods.
1691
+ * @param {object} [options] the options object passed into the openUri methods.
1688
1692
  * @api private
1689
- * @return {Boolean} true if the provided options object provides enough data to authenticate with,
1693
+ * @return {boolean} true if the provided options object provides enough data to authenticate with,
1690
1694
  * otherwise false.
1691
1695
  */
1692
1696
  Connection.prototype.optionsProvideAuthenticationData = function optionsProvideAuthenticationData(options) {
@@ -1696,7 +1700,7 @@ Connection.prototype.optionsProvideAuthenticationData = function optionsProvideA
1696
1700
  };
1697
1701
 
1698
1702
  /**
1699
- * Returns the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html) instance
1703
+ * Returns the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/7.0/classes/MongoClient.html) instance
1700
1704
  * that this connection uses to talk to MongoDB.
1701
1705
  *
1702
1706
  * #### Example:
@@ -1715,7 +1719,7 @@ Connection.prototype.getClient = function getClient() {
1715
1719
  };
1716
1720
 
1717
1721
  /**
1718
- * Set the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html) instance
1722
+ * Set the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/7.0/classes/MongoClient.html) instance
1719
1723
  * that this connection uses to talk to MongoDB. This is useful if you already have a MongoClient instance, and want to
1720
1724
  * reuse it.
1721
1725
  *
@@ -1748,9 +1752,9 @@ Connection.prototype.createClient = function createClient() {
1748
1752
  /**
1749
1753
  * Syncs all the indexes for the models registered with this connection.
1750
1754
  *
1751
- * @param {Object} [options]
1752
- * @param {Boolean} [options.continueOnError] `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
1753
- * @return {Promise<Object>} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1755
+ * @param {object} [options]
1756
+ * @param {boolean} [options.continueOnError] `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
1757
+ * @return {Promise<object>} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1754
1758
  */
1755
1759
  Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1756
1760
  const result = {};
@@ -1772,7 +1776,7 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1772
1776
  }
1773
1777
  }
1774
1778
 
1775
- if (!continueOnError && Object.keys(errorsMap).length) {
1779
+ if (!continueOnError && utils.hasOwnKeys(errorsMap)) {
1776
1780
  const message = Object.entries(errorsMap).map(([modelName, err]) => `${modelName}: ${err.message}`).join(', ');
1777
1781
  const syncIndexesError = new SyncIndexesError(message, errorsMap);
1778
1782
  throw syncIndexesError;
@@ -1782,7 +1786,7 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1782
1786
  };
1783
1787
 
1784
1788
  /**
1785
- * Switches to a different database using the same [connection pool](https://mongoosejs.com/docs/api/connectionshtml#connection_pools).
1789
+ * Switches to a different database using the same [connection pool](https://mongoosejs.com/docs/connections.html#connection_pools).
1786
1790
  *
1787
1791
  * Returns a new connection object, with the new db.
1788
1792
  *
@@ -1799,10 +1803,9 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1799
1803
  *
1800
1804
  * @method useDb
1801
1805
  * @memberOf Connection
1802
- * @param {String} name The database name
1803
- * @param {Object} [options]
1804
- * @param {Boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
1805
- * @param {Boolean} [options.noListener=false] If true, the connection object will not make the db listen to events on the original connection. See [issue #9961](https://github.com/Automattic/mongoose/issues/9961).
1806
+ * @param {string} name The database name
1807
+ * @param {object} [options]
1808
+ * @param {boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
1806
1809
  * @return {Connection} New Connection Object
1807
1810
  * @api public
1808
1811
  */
@@ -1813,8 +1816,8 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1813
1816
  * @method aggregate
1814
1817
  * @memberOf Connection
1815
1818
  * @param {Array} pipeline
1816
- * @param {Object} [options]
1817
- * @param {Boolean} [options.cursor=false] If true, make the Aggregate resolve to a Mongoose AggregationCursor rather than an array
1819
+ * @param {object} [options]
1820
+ * @param {boolean} [options.cursor=false] If true, make the Aggregate resolve to a Mongoose AggregationCursor rather than an array
1818
1821
  * @return {Aggregate} Aggregation wrapper
1819
1822
  * @api public
1820
1823
  */
@@ -1837,7 +1840,7 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1837
1840
  *
1838
1841
  * @method removeDb
1839
1842
  * @memberOf Connection
1840
- * @param {String} name The database name
1843
+ * @param {string} name The database name
1841
1844
  * @return {Connection} this
1842
1845
  * @api public
1843
1846
  */