@nullix/zod-mongoose-studio 1.0.13 → 2.0.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 (314) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{Db4IAypj.js → 0J_bLG6U.js} +1 -1
  3. package/.output/public/_nuxt/{Y39o1QEi.js → 5KLjKHc1.js} +1 -1
  4. package/.output/public/_nuxt/{B4zoPYF-.js → B2UrsJHg.js} +1 -1
  5. package/.output/public/_nuxt/{BSqjh6Vk.js → BC5hGokz.js} +1 -1
  6. package/.output/public/_nuxt/{BS4yU4O0.js → BJwN20Xm.js} +1 -1
  7. package/.output/public/_nuxt/{D8_n84hl.js → BMgDPqps.js} +1 -1
  8. package/.output/public/_nuxt/{CqNsQbt9.js → B_sGF2qN.js} +1 -1
  9. package/.output/public/_nuxt/{NAqlztEN.js → BeaJ7I-K.js} +10 -10
  10. package/.output/public/_nuxt/{WZ0WK9cR.js → BkE1sm_1.js} +1 -1
  11. package/.output/public/_nuxt/{kBtP64Rx.js → CADbZwE5.js} +1 -1
  12. package/.output/public/_nuxt/{B8qGaxNm.js → CB0WRoVi.js} +1 -1
  13. package/.output/public/_nuxt/{BV6uALfO.js → CCh0PVV0.js} +1 -1
  14. package/.output/public/_nuxt/{CP9Z7-_9.js → Cr0GW7rA.js} +1 -1
  15. package/.output/public/_nuxt/{DeCqoVOS.js → DJe7Wxdv.js} +1 -1
  16. package/.output/public/_nuxt/{dBZQW7JD.js → DRBrUaE5.js} +1 -1
  17. package/.output/public/_nuxt/{Db19R32y.js → DV2n9B6m.js} +1 -1
  18. package/.output/public/_nuxt/{CvnpbYw0.js → DVD-jGiv.js} +1 -1
  19. package/.output/public/_nuxt/{BWajNATZ.js → Dk9qGA5X.js} +3 -3
  20. package/.output/public/_nuxt/builds/latest.json +1 -1
  21. package/.output/public/_nuxt/builds/meta/dc761332-547d-4953-b51d-b2d453009b48.json +1 -0
  22. package/.output/public/_nuxt/error-404.64pZEiDn.css +1 -0
  23. package/.output/public/_nuxt/error-500.DHOpI0Ir.css +1 -0
  24. package/.output/public/_nuxt/{BoHhCIKW.js → koEZfutw.js} +3 -3
  25. package/.output/public/_nuxt/{B_782F4p.js → r6LdR7DN.js} +1 -1
  26. package/.output/public/_nuxt/{BEI71c6K.js → rEfOp38p.js} +1 -1
  27. package/.output/server/chunks/_/error-500.mjs.map +1 -1
  28. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  29. package/.output/server/chunks/build/{error-404-8tbBXju4.mjs → error-404-BN-7rNE4.mjs} +4 -4
  30. package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +1 -0
  31. package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +8 -0
  32. package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +1 -0
  33. package/.output/server/chunks/build/{error-500-DxFsom1i.mjs → error-500-DhIQ-2yt.mjs} +4 -4
  34. package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +1 -0
  35. package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +8 -0
  36. package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +1 -0
  37. package/.output/server/chunks/build/{index-BB-Clavm.mjs → index-Dnrh1ePF.mjs} +1 -1
  38. package/.output/server/chunks/build/index-Dnrh1ePF.mjs.map +1 -0
  39. package/.output/server/chunks/build/server.mjs +9 -9
  40. package/.output/server/chunks/build/styles.mjs +4 -4
  41. package/.output/server/chunks/nitro/nitro.mjs +333 -333
  42. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  43. package/.output/server/chunks/routes/renderer.mjs.map +1 -1
  44. package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
  45. package/.output/server/node_modules/bson/package.json +9 -11
  46. package/.output/server/node_modules/kareem/index.js +228 -343
  47. package/.output/server/node_modules/kareem/package.json +3 -3
  48. package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
  49. package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
  50. package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
  51. package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
  52. package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
  53. package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
  54. package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  55. package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
  56. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  57. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
  58. package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
  59. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
  60. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
  61. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
  62. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
  63. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
  64. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
  65. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
  66. package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
  67. package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
  68. package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
  69. package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
  70. package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
  71. package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
  72. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
  73. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
  74. package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
  75. package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
  76. package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
  77. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
  78. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
  79. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
  80. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
  81. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
  82. package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
  83. package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
  84. package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
  85. package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
  86. package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
  87. package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
  88. package/.output/server/node_modules/mongodb/lib/db.js +6 -7
  89. package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
  90. package/.output/server/node_modules/mongodb/lib/error.js +7 -10
  91. package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
  92. package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
  93. package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
  94. package/.output/server/node_modules/mongodb/lib/index.js +2 -4
  95. package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
  96. package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
  97. package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
  98. package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
  99. package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
  100. package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
  101. package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
  102. package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  103. package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
  104. package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
  105. package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
  106. package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  107. package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
  108. package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
  109. package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
  110. package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
  111. package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
  112. package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
  113. package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
  114. package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
  115. package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
  116. package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
  117. package/.output/server/node_modules/mongodb/package.json +49 -45
  118. package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
  119. package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
  120. package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
  121. package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
  122. package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
  123. package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
  124. package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
  125. package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
  126. package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
  127. package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
  128. package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
  129. package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
  130. package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
  131. package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
  132. package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
  133. package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
  134. package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
  135. package/.output/server/node_modules/mongoose/lib/document.js +712 -531
  136. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
  137. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
  138. package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
  139. package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
  140. package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
  141. package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
  142. package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
  143. package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
  144. package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
  145. package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
  146. package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
  147. package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
  148. package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
  149. package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
  150. package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
  151. package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
  152. package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
  153. package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
  154. package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
  155. package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  156. package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  157. package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
  158. package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
  159. package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
  160. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
  161. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  162. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  163. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
  164. package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
  165. package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
  166. package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
  167. package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
  168. package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
  169. package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
  170. package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  171. package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  172. package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
  173. package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  174. package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
  175. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
  176. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  177. package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
  178. package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
  179. package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
  180. package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
  181. package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
  182. package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  183. package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
  184. package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
  185. package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
  186. package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
  187. package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
  188. package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
  189. package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
  190. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
  191. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
  192. package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
  193. package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
  194. package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
  195. package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  196. package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
  197. package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  198. package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
  199. package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
  200. package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
  201. package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
  202. package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
  203. package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
  204. package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
  205. package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
  206. package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
  207. package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
  208. package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
  209. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
  210. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
  211. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
  212. package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
  213. package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
  214. package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
  215. package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
  216. package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
  217. package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
  218. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  219. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
  220. package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
  221. package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
  222. package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
  223. package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
  224. package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
  225. package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
  226. package/.output/server/node_modules/mongoose/lib/model.js +940 -946
  227. package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
  228. package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
  229. package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
  230. package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
  231. package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
  232. package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
  233. package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
  234. package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
  235. package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
  236. package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
  237. package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
  238. package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
  239. package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
  240. package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
  241. package/.output/server/node_modules/mongoose/lib/query.js +700 -548
  242. package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
  243. package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
  244. package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
  245. package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
  246. package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
  247. package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
  248. package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
  249. package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
  250. package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
  251. package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
  252. package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
  253. package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
  254. package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
  255. package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
  256. package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
  257. package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
  258. package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
  259. package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
  260. package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
  261. package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
  262. package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
  263. package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
  264. package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
  265. package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
  266. package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
  267. package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
  268. package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
  269. package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
  270. package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
  271. package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
  272. package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
  273. package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
  274. package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
  275. package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
  276. package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
  277. package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
  278. package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
  279. package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
  280. package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
  281. package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
  282. package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
  283. package/.output/server/node_modules/mongoose/package.json +46 -63
  284. package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
  285. package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
  286. package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
  287. package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
  288. package/.output/server/node_modules/mquery/package.json +4 -7
  289. package/.output/server/package.json +7 -9
  290. package/package.json +3 -3
  291. package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
  292. package/.output/public/_nuxt/error-404.CTWLHxjC.css +0 -1
  293. package/.output/public/_nuxt/error-500.UBfk8-QP.css +0 -1
  294. package/.output/server/chunks/build/error-404-8tbBXju4.mjs.map +0 -1
  295. package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs +0 -8
  296. package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs.map +0 -1
  297. package/.output/server/chunks/build/error-500-DxFsom1i.mjs.map +0 -1
  298. package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs +0 -8
  299. package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs.map +0 -1
  300. package/.output/server/chunks/build/index-BB-Clavm.mjs.map +0 -1
  301. package/.output/server/node_modules/debug/package.json +0 -64
  302. package/.output/server/node_modules/debug/src/browser.js +0 -272
  303. package/.output/server/node_modules/debug/src/common.js +0 -292
  304. package/.output/server/node_modules/debug/src/index.js +0 -10
  305. package/.output/server/node_modules/debug/src/node.js +0 -263
  306. package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
  307. package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
  308. package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
  309. package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
  310. package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
  311. package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
  312. package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
  313. package/.output/server/node_modules/supports-color/index.js +0 -202
  314. package/.output/server/node_modules/supports-color/package.json +0 -64
@@ -9,7 +9,7 @@ const MongooseError = require('./mongooseError');
9
9
 
10
10
  /**
11
11
  * MissingSchema Error constructor.
12
- * @param {String} name
12
+ * @param {string} name
13
13
  * @api private
14
14
  */
15
15
 
@@ -10,17 +10,16 @@ const MongooseError = require('./mongooseError');
10
10
  * Constructor for errors that happen when a parameter that's expected to be
11
11
  * an object isn't an object
12
12
  *
13
- * @param {Any} value
14
- * @param {String} paramName
15
- * @param {String} fnName
13
+ * @param {any} value
14
+ * @param {string} paramName
15
+ * @param {string} fnName
16
16
  * @api private
17
17
  */
18
18
 
19
19
  class ObjectParameterError extends MongooseError {
20
-
21
20
  constructor(value, paramName, fnName) {
22
21
  super('Parameter "' + paramName + '" to ' + fnName +
23
- '() must be an object, got "' + (value?.toString() ?? (value + '')) + '" (type ' + typeof value + ')');
22
+ '() must be an object, got "' + (value == null ? value : value.toString()) + '" (type ' + typeof value + ')');
24
23
  }
25
24
  }
26
25
 
@@ -9,7 +9,7 @@ const MongooseError = require('./mongooseError');
9
9
 
10
10
  /**
11
11
  * OverwriteModel Error constructor.
12
- * @param {String} name
12
+ * @param {string} name
13
13
  * @api private
14
14
  */
15
15
 
@@ -40,8 +40,8 @@ class SetOptionError extends MongooseError {
40
40
 
41
41
  /**
42
42
  * add message
43
- * @param {String} key
44
- * @param {String|Error} error
43
+ * @param {string} key
44
+ * @param {string|Error} error
45
45
  * @api private
46
46
  */
47
47
  addError(key, error) {
@@ -87,7 +87,7 @@ Object.defineProperty(SetOptionError.prototype, 'name', {
87
87
  class SetOptionInnerError extends MongooseError {
88
88
  /**
89
89
  * Error for the "errors" array in "SetOptionError" with consistent message
90
- * @param {String} key
90
+ * @param {string} key
91
91
  */
92
92
  constructor(key) {
93
93
  super(`"${key}" is not a valid option to set`);
@@ -9,9 +9,9 @@ const MongooseError = require('./mongooseError');
9
9
  /**
10
10
  * Strict mode error constructor
11
11
  *
12
- * @param {String} path
13
- * @param {String} [msg]
14
- * @param {Boolean} [immutable]
12
+ * @param {string} path
13
+ * @param {string} [msg]
14
+ * @param {boolean} [immutable]
15
15
  * @inherits MongooseError
16
16
  * @api private
17
17
  */
@@ -9,8 +9,8 @@ const MongooseError = require('./mongooseError');
9
9
  /**
10
10
  * Strict mode error constructor
11
11
  *
12
- * @param {String} path
13
- * @param {String} [msg]
12
+ * @param {string} path
13
+ * @param {string} [msg]
14
14
  * @inherits MongooseError
15
15
  * @api private
16
16
  */
@@ -9,8 +9,8 @@ const MongooseError = require('./mongooseError');
9
9
  /**
10
10
  * SyncIndexes Error constructor.
11
11
  *
12
- * @param {String} message
13
- * @param {String} errorsMap
12
+ * @param {string} message
13
+ * @param {string} errorsMap
14
14
  * @inherits MongooseError
15
15
  * @api private
16
16
  */
@@ -44,18 +44,10 @@ class ValidationError extends MongooseError {
44
44
  return this.name + ': ' + combinePathErrors(this);
45
45
  }
46
46
 
47
- /**
48
- * inspect helper
49
- * @api private
50
- */
51
- inspect() {
52
- return Object.assign(new Error(this.message), this);
53
- }
54
-
55
47
  /**
56
48
  * add message
57
- * @param {String} path
58
- * @param {String|Error} error
49
+ * @param {string} path
50
+ * @param {string|Error} error
59
51
  * @api private
60
52
  */
61
53
  addError(path, error) {
@@ -9,7 +9,7 @@ const MongooseError = require('./mongooseError');
9
9
  /**
10
10
  * Schema validator error
11
11
  *
12
- * @param {Object} properties
12
+ * @param {object} properties
13
13
  * @param {Document} doc
14
14
  * @api private
15
15
  */
@@ -10,8 +10,8 @@ const MongooseError = require('./mongooseError');
10
10
  * Version Error constructor.
11
11
  *
12
12
  * @param {Document} doc
13
- * @param {Number} currentVersion
14
- * @param {Array<String>} modifiedPaths
13
+ * @param {number} currentVersion
14
+ * @param {string[]} modifiedPaths
15
15
  * @api private
16
16
  */
17
17
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = function prepareDiscriminatorPipeline(pipeline, schema, prefix) {
4
- const discriminatorMapping = schema && schema.discriminatorMapping;
4
+ const discriminatorMapping = schema?.discriminatorMapping;
5
5
  prefix = prefix || '';
6
6
 
7
7
  if (discriminatorMapping && !discriminatorMapping.isRoot) {
@@ -18,12 +18,12 @@ module.exports = function prepareDiscriminatorPipeline(pipeline, schema, prefix)
18
18
  originalPipeline[0].$match[filterKey] = discriminatorValue;
19
19
  // `originalPipeline` is a ref, so there's no need for
20
20
  // aggregate._pipeline = originalPipeline
21
- } else if (originalPipeline[0] != null && originalPipeline[0].$geoNear) {
21
+ } else if (originalPipeline[0]?.$geoNear) {
22
22
  originalPipeline[0].$geoNear.query =
23
23
  originalPipeline[0].$geoNear.query || {};
24
24
  originalPipeline[0].$geoNear.query[filterKey] = discriminatorValue;
25
- } else if (originalPipeline[0] != null && originalPipeline[0].$search) {
26
- if (originalPipeline[1] && originalPipeline[1].$match != null) {
25
+ } else if (originalPipeline[0]?.$search) {
26
+ if (originalPipeline[1]?.$match != null) {
27
27
  originalPipeline[1].$match[filterKey] = originalPipeline[1].$match[filterKey] || discriminatorValue;
28
28
  } else {
29
29
  const match = {};
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const symbols = require('../schema/symbols');
4
+
5
+ /**
6
+ * Filter predicate that returns true for built-in middleware (marked with `builtInMiddleware` symbol).
7
+ */
8
+ const isBuiltInMiddleware = hook => hook.fn[symbols.builtInMiddleware];
9
+
10
+ /**
11
+ * Builds a filter for kareem's execPre/execPost based on middleware options.
12
+ *
13
+ * @param {object} options - Options object that may contain `middleware` setting
14
+ * @param {string} phase - Either 'pre' or 'post'
15
+ * @returns {Function|null} - null runs all middleware, isBuiltInMiddleware skips user middleware
16
+ */
17
+ function buildMiddlewareFilter(options, phase) {
18
+ const shouldRun = options?.middleware?.[phase] ?? options?.middleware ?? true;
19
+ return shouldRun ? null : isBuiltInMiddleware;
20
+ }
21
+
22
+ module.exports = {
23
+ buildMiddlewareFilter
24
+ };
@@ -11,10 +11,10 @@ const isObject = require('./isObject');
11
11
  const isPOJO = require('./isPOJO');
12
12
  const symbols = require('./symbols');
13
13
  const trustedSymbol = require('./query/trusted').trustedSymbol;
14
- const BSON = require('bson');
14
+ const BSON = require('mongodb/lib/bson');
15
+ const UUID = BSON.UUID;
15
16
 
16
17
  const Binary = BSON.Binary;
17
- const UUID = BSON.UUID;
18
18
 
19
19
  /**
20
20
  * Object clone with Mongoose natives support.
@@ -23,10 +23,10 @@ const UUID = BSON.UUID;
23
23
  *
24
24
  * Functions and primitives are never cloned.
25
25
  *
26
- * @param {Object} obj the object to clone
27
- * @param {Object} options
28
- * @param {Boolean} isArrayChild true if cloning immediately underneath an array. Special case for minimize.
29
- * @return {Object} the cloned object
26
+ * @param {object} obj the object to clone
27
+ * @param {object} options
28
+ * @param {boolean} isArrayChild true if cloning immediately underneath an array. Special case for minimize.
29
+ * @return {object} the cloned object
30
30
  * @api private
31
31
  */
32
32
 
@@ -83,7 +83,7 @@ function clone(obj, options, isArrayChild) {
83
83
  }
84
84
 
85
85
  let ret;
86
- if (options && options.json && typeof obj.toJSON === 'function') {
86
+ if (options?.json && typeof obj.toJSON === 'function') {
87
87
  ret = obj.toJSON(options);
88
88
  } else {
89
89
  ret = obj.toObject(options);
@@ -109,14 +109,14 @@ function clone(obj, options, isArrayChild) {
109
109
  }
110
110
 
111
111
  if (isBsonType(obj, 'ObjectId')) {
112
- if (options && options.flattenObjectIds) {
112
+ if (options?.flattenObjectIds) {
113
113
  return obj.toJSON();
114
114
  }
115
115
  return new ObjectId(obj.id);
116
116
  }
117
117
 
118
118
  if (isBsonType(obj, 'Decimal128')) {
119
- if (options && options.flattenDecimals) {
119
+ if (options?.flattenDecimals) {
120
120
  return obj.toJSON();
121
121
  }
122
122
  return Decimal.fromString(obj.toString());
@@ -141,7 +141,7 @@ function clone(obj, options, isArrayChild) {
141
141
  // If we're cloning this object to go into a MongoDB command,
142
142
  // and there's a `toBSON()` function, assume this object will be
143
143
  // stored as a primitive in MongoDB and doesn't need to be cloned.
144
- if (options && options.bson && typeof obj.toBSON === 'function') {
144
+ if (options?.bson && typeof obj.toBSON === 'function') {
145
145
  return obj;
146
146
  }
147
147
 
@@ -158,9 +158,9 @@ module.exports = clone;
158
158
  */
159
159
 
160
160
  function cloneObject(obj, options, isArrayChild) {
161
- const minimize = options && options.minimize;
162
- const omitUndefined = options && options.omitUndefined;
163
- const seen = options && options._seen;
161
+ const minimize = options?.minimize;
162
+ const omitUndefined = options?.omitUndefined;
163
+ const seen = options?._seen;
164
164
  const ret = {};
165
165
  let hasKeys;
166
166
 
@@ -202,10 +202,15 @@ function cloneArray(arr, options) {
202
202
 
203
203
  let ret = null;
204
204
  if (options?.retainDocuments) {
205
+ // Use the cloned parent doc (options.parentDoc) when available so the new
206
+ // array is wired up to the clone, not the source. Falling back to the
207
+ // source's parent preserves the previous behavior for callers that don't
208
+ // pass parentDoc.
209
+ const newParent = options.parentDoc ?? (arr.isMongooseArray ? arr.$parent() : undefined);
205
210
  if (arr.isMongooseDocumentArray) {
206
- ret = new (arr.$schemaType().schema.base.Types.DocumentArray)([], arr.$path(), arr.$parent(), arr.$schemaType());
211
+ ret = new (arr.$schemaType().schema.base.Types.DocumentArray)([], arr.$path(), newParent, arr.$schemaType());
207
212
  } else if (arr.isMongooseArray) {
208
- ret = new (arr.$parent().schema.base.Types.Array)([], arr.$path(), arr.$parent(), arr.$schemaType());
213
+ ret = new (arr.$parent().schema.base.Types.Array)([], arr.$path(), newParent, arr.$schemaType());
209
214
  } else {
210
215
  ret = new Array(len);
211
216
  }
@@ -218,9 +223,21 @@ function cloneArray(arr, options) {
218
223
  // Create new options object to avoid mutating the shared options.
219
224
  // Subdocs need parentArray to point to their own cloned array.
220
225
  options = { ...options, parentArray: ret };
221
- }
222
- for (i = 0; i < len; ++i) {
223
- ret[i] = clone(arr[i], options, true);
226
+ // Skip change-tracking while populating the freshly cloned array: every
227
+ // index assignment would otherwise call markModified on the cloned parent
228
+ // doc and (before this guard) on the source parent doc.
229
+ for (i = 0; i < len; ++i) {
230
+ const doc = clone(arr[i], options, true);
231
+ // Document arrays can contain null entries, so only restamp actual subdocs.
232
+ if (typeof doc?.$setIndex === 'function') {
233
+ doc.$setIndex(i);
234
+ }
235
+ ret.set(i, doc, true);
236
+ }
237
+ } else {
238
+ for (i = 0; i < len; ++i) {
239
+ ret[i] = clone(arr[i], options, true);
240
+ }
224
241
  }
225
242
 
226
243
  return ret;
@@ -4,7 +4,7 @@
4
4
  * Module dependencies.
5
5
  */
6
6
 
7
- const Binary = require('bson').Binary;
7
+ const Binary = require('mongodb/lib/bson').Binary;
8
8
  const isBsonType = require('./isBsonType');
9
9
  const isMongooseObject = require('./isMongooseObject');
10
10
  const MongooseError = require('../error');
@@ -35,12 +35,12 @@ function flatten(update, path, options, schema) {
35
35
  result[path + key] = val;
36
36
 
37
37
  // Avoid going into mixed paths if schema is specified
38
- const keySchema = schema && schema.path && schema.path(path + key);
39
- const isNested = schema && schema.nested && schema.nested[path + key];
40
- if (keySchema && keySchema.instance === 'Mixed') continue;
38
+ const keySchema = schema?.path?.(path + key);
39
+ const isNested = schema?.nested?.[path + key];
40
+ if (keySchema?.instance === 'Mixed') continue;
41
41
 
42
42
  if (shouldFlatten(val)) {
43
- if (options && options.skipArrays && Array.isArray(val)) {
43
+ if (options?.skipArrays && Array.isArray(val)) {
44
44
  continue;
45
45
  }
46
46
  const flat = flatten(val, path + key, options, schema);
@@ -14,9 +14,9 @@ const immediate = require('../immediate');
14
14
  *
15
15
  * @param {Function} next the thunk to call to get the next document
16
16
  * @param {Function} fn
17
- * @param {Object} options
18
- * @param {Number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
19
- * @param {Number} [options.parallel=1] maximum number of `fn` calls that Mongoose will run in parallel
17
+ * @param {object} options
18
+ * @param {number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
19
+ * @param {number} [options.parallel=1] maximum number of `fn` calls that Mongoose will run in parallel
20
20
  * @param {AbortSignal} [options.signal] allow cancelling this eachAsync(). Once the abort signal is fired, `eachAsync()` will immediately fulfill the returned promise (or call the callback) and not fetch any more documents.
21
21
  * @return {Promise}
22
22
  * @api public
@@ -174,7 +174,7 @@ module.exports = async function eachAsync(next, fn, options) {
174
174
  } catch (err) {
175
175
  return callback(err);
176
176
  }
177
- if (maybePromise && typeof maybePromise.then === 'function') {
177
+ if (typeof maybePromise?.then === 'function') {
178
178
  maybePromise.then(
179
179
  function() { callback(null); },
180
180
  function(error) {
@@ -9,7 +9,7 @@ const getDiscriminatorByValue = require('./getDiscriminatorByValue');
9
9
 
10
10
  module.exports = function getConstructor(Constructor, value, defaultDiscriminatorValue) {
11
11
  const discriminatorKey = Constructor.schema.options.discriminatorKey;
12
- let discriminatorValue = (value != null && value[discriminatorKey]);
12
+ let discriminatorValue = value?.[discriminatorKey];
13
13
  if (discriminatorValue == null) {
14
14
  discriminatorValue = defaultDiscriminatorValue;
15
15
  }
@@ -5,7 +5,7 @@ const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
5
5
  /**
6
6
  * returns discriminator by discriminatorMapping.value
7
7
  *
8
- * @param {Object} discriminators
8
+ * @param {object} discriminators
9
9
  * @param {string} value
10
10
  * @api private
11
11
  */
@@ -11,7 +11,7 @@ const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
11
11
  */
12
12
 
13
13
  module.exports = function getSchemaDiscriminatorByValue(schema, value) {
14
- if (schema == null || schema.discriminators == null) {
14
+ if (schema?.discriminators == null) {
15
15
  return null;
16
16
  }
17
17
  for (const key of Object.keys(schema.discriminators)) {
@@ -8,9 +8,9 @@ const isObject = require('../../helpers/isObject');
8
8
  /**
9
9
  * Merges `from` into `to` without overwriting existing properties.
10
10
  *
11
- * @param {Object} to
12
- * @param {Object} from
13
- * @param {String} [path]
11
+ * @param {object} to
12
+ * @param {object} from
13
+ * @param {string} [path]
14
14
  * @api private
15
15
  */
16
16
 
@@ -40,12 +40,17 @@ module.exports = function mergeDiscriminatorSchema(to, from, path, seen) {
40
40
  continue;
41
41
  }
42
42
  }
43
- if (path === 'tree' && from != null && from.instanceOfSchema) {
43
+ if (path === 'tree' && from?.instanceOfSchema) {
44
44
  continue;
45
45
  }
46
46
  if (specialProperties.has(key)) {
47
47
  continue;
48
48
  }
49
+ if (key === 'parentSchema') {
50
+ // Skip parentSchema to avoid merging parent schema multiple times
51
+ // through child paths' back-references (gh-15966)
52
+ continue;
53
+ }
49
54
  if (to[key] == null) {
50
55
  to[key] = from[key];
51
56
  } else if (isObject(from[key])) {
@@ -85,7 +90,7 @@ module.exports = function mergeDiscriminatorSchema(to, from, path, seen) {
85
90
  }
86
91
  }
87
92
 
88
- if (from != null && from.instanceOfSchema) {
93
+ if (from?.instanceOfSchema) {
89
94
  to.tree = Object.assign({}, from.tree, to.tree);
90
95
  }
91
96
  };
@@ -5,7 +5,7 @@ const isNestedProjection = require('../projection/isNestedProjection');
5
5
  module.exports = function applyDefaults(doc, fields, exclude, hasIncludedChildren, isBeforeSetters, pathsToSkip, options) {
6
6
  const paths = Object.keys(doc.$__schema.paths);
7
7
  const plen = paths.length;
8
- const skipParentChangeTracking = options && options.skipParentChangeTracking;
8
+ const skipParentChangeTracking = options?.skipParentChangeTracking;
9
9
 
10
10
  for (let i = 0; i < plen; ++i) {
11
11
  let def;
@@ -2,6 +2,7 @@
2
2
 
3
3
  const handleTimestampOption = require('../schema/handleTimestampOption');
4
4
  const mpath = require('mpath');
5
+ const utils = require('../../utils');
5
6
 
6
7
  module.exports = applyTimestamps;
7
8
 
@@ -9,9 +10,9 @@ module.exports = applyTimestamps;
9
10
  * Apply a given schema's timestamps to the given POJO
10
11
  *
11
12
  * @param {Schema} schema
12
- * @param {Object} obj
13
- * @param {Object} [options]
14
- * @param {Boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
13
+ * @param {object} obj
14
+ * @param {object} [options]
15
+ * @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
15
16
  * @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
16
17
  */
17
18
 
@@ -28,9 +29,9 @@ function applyTimestamps(schema, obj, options) {
28
29
  * Apply timestamps to any subdocuments
29
30
  *
30
31
  * @param {Schema} schema subdocument schema
31
- * @param {Object} res subdocument
32
- * @param {Object} [options]
33
- * @param {Boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
32
+ * @param {object} res subdocument
33
+ * @param {object} [options]
34
+ * @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
34
35
  * @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
35
36
  */
36
37
 
@@ -54,9 +55,9 @@ function applyTimestampsToChildren(schema, res, options) {
54
55
  * Apply timestamps to a given document. Does not apply timestamps to subdocuments: use `applyTimestampsToChildren` instead
55
56
  *
56
57
  * @param {Schema} schema
57
- * @param {Object} obj
58
- * @param {Object} [options]
59
- * @param {Boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
58
+ * @param {object} obj
59
+ * @param {object} [options]
60
+ * @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
60
61
  * @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
61
62
  */
62
63
 
@@ -71,7 +72,7 @@ function applyTimestampsToDoc(schema, obj, options) {
71
72
  return;
72
73
  }
73
74
 
74
- if (schema.discriminators && Object.keys(schema.discriminators).length > 0) {
75
+ if (schema.discriminators && utils.hasOwnKeys(schema.discriminators)) {
75
76
  for (const discriminatorKey of Object.keys(schema.discriminators)) {
76
77
  const discriminator = schema.discriminators[discriminatorKey];
77
78
  const key = discriminator.discriminatorMapping.key;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const mpath = require('mpath');
4
+ const utils = require('../../utils');
4
5
 
5
6
  module.exports = applyVirtuals;
6
7
 
@@ -8,8 +9,8 @@ module.exports = applyVirtuals;
8
9
  * Apply a given schema's virtuals to a given POJO
9
10
  *
10
11
  * @param {Schema} schema
11
- * @param {Object} obj
12
- * @param {Array<string>} [virtuals] optional whitelist of virtuals to apply
12
+ * @param {object} obj
13
+ * @param {string[]} [virtuals] optional whitelist of virtuals to apply
13
14
  * @returns
14
15
  */
15
16
 
@@ -41,8 +42,8 @@ function applyVirtuals(schema, obj, virtuals) {
41
42
  * Apply virtuals to any subdocuments
42
43
  *
43
44
  * @param {Schema} schema subdocument schema
44
- * @param {Object} res subdocument
45
- * @param {Array<String>} [virtuals] optional whitelist of virtuals to apply
45
+ * @param {object} res subdocument
46
+ * @param {string[]} [virtuals] optional whitelist of virtuals to apply
46
47
  */
47
48
 
48
49
  function applyVirtualsToChildren(schema, res, virtuals) {
@@ -76,7 +77,7 @@ function applyVirtualsToChildren(schema, res, virtuals) {
76
77
  attachedVirtuals = true;
77
78
  }
78
79
 
79
- if (virtuals && virtuals.length && !attachedVirtuals) {
80
+ if (virtuals?.length && !attachedVirtuals) {
80
81
  applyVirtualsToDoc(schema, res, virtuals);
81
82
  }
82
83
  }
@@ -85,8 +86,8 @@ function applyVirtualsToChildren(schema, res, virtuals) {
85
86
  * Apply virtuals to a given document. Does not apply virtuals to subdocuments: use `applyVirtualsToChildren` instead
86
87
  *
87
88
  * @param {Schema} schema
88
- * @param {Object} doc
89
- * @param {Array<String>} [virtuals] optional whitelist of virtuals to apply
89
+ * @param {object} doc
90
+ * @param {string[]} [virtuals] optional whitelist of virtuals to apply
90
91
  * @returns
91
92
  */
92
93
 
@@ -101,7 +102,7 @@ function applyVirtualsToDoc(schema, obj, virtuals) {
101
102
  return;
102
103
  }
103
104
 
104
- if (schema.discriminators && Object.keys(schema.discriminators).length > 0) {
105
+ if (schema.discriminators && utils.hasOwnKeys(schema.discriminators)) {
105
106
  for (const discriminatorKey of Object.keys(schema.discriminators)) {
106
107
  const discriminator = schema.discriminators[discriminatorKey];
107
108
  const key = discriminator.discriminatorMapping.key;
@@ -133,7 +134,7 @@ function applyVirtualsToDoc(schema, obj, virtuals) {
133
134
  }
134
135
  let val = virtualType.applyGetters(cur[sp[sp.length - 1]], obj);
135
136
  const isPopulateVirtual =
136
- virtualType.options && (virtualType.options.ref || virtualType.options.refPath);
137
+ virtualType.options?.ref || virtualType.options?.refPath;
137
138
  if (isPopulateVirtual && val === undefined) {
138
139
  if (virtualType.options.justOne) {
139
140
  val = null;
@@ -16,7 +16,7 @@ module.exports = function cleanModifiedSubpaths(doc, path, options) {
16
16
  for (const modifiedPath of Object.keys(doc.$__.activePaths.getStatePaths('modify'))) {
17
17
  if (skipDocArrays) {
18
18
  const schemaType = doc.$__schema.path(modifiedPath);
19
- if (schemaType && schemaType.$isMongooseDocumentArray) {
19
+ if (schemaType?.$isMongooseDocumentArray) {
20
20
  continue;
21
21
  }
22
22
  }
@@ -31,10 +31,10 @@ const noDottedPathGetOptions = Object.freeze({
31
31
 
32
32
  /**
33
33
  * Compiles schemas.
34
- * @param {Object} tree
35
- * @param {Any} proto
36
- * @param {String} prefix
37
- * @param {Object} options
34
+ * @param {object} tree
35
+ * @param {any} proto
36
+ * @param {string} prefix
37
+ * @param {object} options
38
38
  * @api private
39
39
  */
40
40
 
@@ -46,7 +46,7 @@ function compile(tree, proto, prefix, options) {
46
46
  const limb = tree[key];
47
47
 
48
48
  const hasSubprops = isPOJO(limb) &&
49
- Object.keys(limb).length > 0 &&
49
+ utils.hasOwnKeys(limb) &&
50
50
  (!limb[typeKey] || (typeKey === 'type' && isPOJO(limb.type) && limb.type.type));
51
51
  const subprops = hasSubprops ? limb : null;
52
52
 
@@ -56,12 +56,12 @@ function compile(tree, proto, prefix, options) {
56
56
 
57
57
  /**
58
58
  * Defines the accessor named prop on the incoming prototype.
59
- * @param {Object} options
60
- * @param {String} options.prop
61
- * @param {Boolean} options.subprops
62
- * @param {Any} options.prototype
63
- * @param {String} [options.prefix]
64
- * @param {Object} options.options
59
+ * @param {object} options
60
+ * @param {string} options.prop
61
+ * @param {boolean} options.subprops
62
+ * @param {any} options.prototype
63
+ * @param {string} [options.prefix]
64
+ * @param {object} options.options
65
65
  * @api private
66
66
  */
67
67
 
@@ -76,6 +76,9 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
76
76
  enumerable: true,
77
77
  configurable: true,
78
78
  get: function() {
79
+ if (!this.$__) {
80
+ return undefined;
81
+ }
79
82
  const _this = this;
80
83
  if (!this.$__.getters) {
81
84
  this.$__.getters = {};
@@ -132,7 +135,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
132
135
  writable: false,
133
136
  value: function() {
134
137
  return _this.get(path, null, {
135
- virtuals: this && this.schema && this.schema.options && this.schema.options.toObject && this.schema.options.toObject.virtuals || null
138
+ virtuals: this?.schema?.options?.toObject?.virtuals || null
136
139
  });
137
140
  }
138
141
  });
@@ -143,7 +146,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
143
146
  writable: false,
144
147
  value: function() {
145
148
  return _this.get(path, null, {
146
- virtuals: this && this.schema && this.schema.options && this.schema.options.toJSON && this.schema.options.toJSON.virtuals || null
149
+ virtuals: this?.schema?.options?.toJSON?.virtuals || null
147
150
  });
148
151
  }
149
152
  });
@@ -178,7 +181,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
178
181
  return this.$__.getters[path];
179
182
  },
180
183
  set: function(v) {
181
- if (v != null && v.$__isNested) {
184
+ if (v?.$__isNested) {
182
185
  // Convert top-level to POJO, but leave subdocs hydrated so `$set`
183
186
  // can handle them. See gh-9293.
184
187
  v = v.$__get();