@nullix/zod-mongoose-studio 1.0.12 → 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 +342 -342
  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/b59771ef-8e58-4078-9d18-ccc01cba96e9.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
@@ -31,7 +31,7 @@ const opts = require('./propertyOptions');
31
31
  * @api public
32
32
  * @property type
33
33
  * @memberOf SchemaTypeOptions
34
- * @type {Function|String|Object}
34
+ * @type {Function|string|object}
35
35
  * @instance
36
36
  */
37
37
 
@@ -43,7 +43,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'type', opts);
43
43
  * @api public
44
44
  * @property validate
45
45
  * @memberOf SchemaTypeOptions
46
- * @type {Function|Object}
46
+ * @type {Function|object}
47
47
  * @instance
48
48
  */
49
49
 
@@ -74,7 +74,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'validate', opts);
74
74
  * @api public
75
75
  * @property cast
76
76
  * @memberOf SchemaTypeOptions
77
- * @type {String}
77
+ * @type {string}
78
78
  * @instance
79
79
  */
80
80
 
@@ -88,12 +88,26 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'cast', opts);
88
88
  * @api public
89
89
  * @property required
90
90
  * @memberOf SchemaTypeOptions
91
- * @type {Function|Boolean}
91
+ * @type {Function|boolean}
92
92
  * @instance
93
93
  */
94
94
 
95
95
  Object.defineProperty(SchemaTypeOptions.prototype, 'required', opts);
96
96
 
97
+ /**
98
+ * Controls whether this path may be set to `null`. By default, Mongoose allows
99
+ * `null` for non-required paths. Set `allowNull: false` to allow `undefined`
100
+ * but disallow `null`.
101
+ *
102
+ * @api public
103
+ * @property allowNull
104
+ * @memberOf SchemaTypeOptions
105
+ * @type {boolean}
106
+ * @instance
107
+ */
108
+
109
+ Object.defineProperty(SchemaTypeOptions.prototype, 'allowNull', opts);
110
+
97
111
  /**
98
112
  * The default value for this path. If a function, Mongoose executes the function
99
113
  * and uses the return value as the default.
@@ -101,7 +115,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'required', opts);
101
115
  * @api public
102
116
  * @property default
103
117
  * @memberOf SchemaTypeOptions
104
- * @type {Function|Any}
118
+ * @type {Function|any}
105
119
  * @instance
106
120
  */
107
121
 
@@ -113,7 +127,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'default', opts);
113
127
  * @api public
114
128
  * @property ref
115
129
  * @memberOf SchemaTypeOptions
116
- * @type {Function|String}
130
+ * @type {Function|string}
117
131
  * @instance
118
132
  */
119
133
 
@@ -126,7 +140,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'ref', opts);
126
140
  * @api public
127
141
  * @property ref
128
142
  * @memberOf SchemaTypeOptions
129
- * @type {Function|String}
143
+ * @type {Function|string}
130
144
  * @instance
131
145
  */
132
146
 
@@ -139,7 +153,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'refPath', opts);
139
153
  * @api public
140
154
  * @property select
141
155
  * @memberOf SchemaTypeOptions
142
- * @type {Boolean|Number}
156
+ * @type {boolean|number}
143
157
  * @instance
144
158
  */
145
159
 
@@ -152,7 +166,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'select', opts);
152
166
  * @api public
153
167
  * @property index
154
168
  * @memberOf SchemaTypeOptions
155
- * @type {Boolean|Number|Object}
169
+ * @type {boolean|number|object}
156
170
  * @instance
157
171
  */
158
172
 
@@ -166,7 +180,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'index', opts);
166
180
  * @api public
167
181
  * @property unique
168
182
  * @memberOf SchemaTypeOptions
169
- * @type {Boolean|Number}
183
+ * @type {boolean|number}
170
184
  * @instance
171
185
  */
172
186
 
@@ -180,7 +194,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'unique', opts);
180
194
  * @api public
181
195
  * @property immutable
182
196
  * @memberOf SchemaTypeOptions
183
- * @type {Function|Boolean}
197
+ * @type {Function|boolean}
184
198
  * @instance
185
199
  */
186
200
 
@@ -193,7 +207,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'immutable', opts);
193
207
  * @api public
194
208
  * @property sparse
195
209
  * @memberOf SchemaTypeOptions
196
- * @type {Boolean|Number}
210
+ * @type {boolean|number}
197
211
  * @instance
198
212
  */
199
213
 
@@ -206,7 +220,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'sparse', opts);
206
220
  * @api public
207
221
  * @property text
208
222
  * @memberOf SchemaTypeOptions
209
- * @type {Boolean|Number|Object}
223
+ * @type {boolean|number|object}
210
224
  * @instance
211
225
  */
212
226
 
@@ -6,7 +6,7 @@ class VirtualOptions {
6
6
  constructor(obj) {
7
7
  Object.assign(this, obj);
8
8
 
9
- if (obj != null && obj.options != null) {
9
+ if (obj?.options != null) {
10
10
  this.options = Object.assign({}, obj.options);
11
11
  }
12
12
  }
@@ -19,7 +19,7 @@ class VirtualOptions {
19
19
  * @api public
20
20
  * @property ref
21
21
  * @memberOf VirtualOptions
22
- * @type {String|Model|Function}
22
+ * @type {string|Model|Function}
23
23
  * @instance
24
24
  */
25
25
 
@@ -32,7 +32,7 @@ Object.defineProperty(VirtualOptions.prototype, 'ref', opts);
32
32
  * @api public
33
33
  * @property refPath
34
34
  * @memberOf VirtualOptions
35
- * @type {String|Function}
35
+ * @type {string|Function}
36
36
  * @instance
37
37
  */
38
38
 
@@ -45,7 +45,7 @@ Object.defineProperty(VirtualOptions.prototype, 'refPath', opts);
45
45
  * @api public
46
46
  * @property localField
47
47
  * @memberOf VirtualOptions
48
- * @type {String|Function}
48
+ * @type {string|Function}
49
49
  * @instance
50
50
  */
51
51
 
@@ -58,7 +58,7 @@ Object.defineProperty(VirtualOptions.prototype, 'localField', opts);
58
58
  * @api public
59
59
  * @property foreignField
60
60
  * @memberOf VirtualOptions
61
- * @type {String|Function}
61
+ * @type {string|Function}
62
62
  * @instance
63
63
  */
64
64
 
@@ -71,7 +71,7 @@ Object.defineProperty(VirtualOptions.prototype, 'foreignField', opts);
71
71
  * @api public
72
72
  * @property justOne
73
73
  * @memberOf VirtualOptions
74
- * @type {Boolean}
74
+ * @type {boolean}
75
75
  * @instance
76
76
  */
77
77
 
@@ -86,7 +86,7 @@ Object.defineProperty(VirtualOptions.prototype, 'justOne', opts);
86
86
  * @api public
87
87
  * @property count
88
88
  * @memberOf VirtualOptions
89
- * @type {Boolean}
89
+ * @type {boolean}
90
90
  * @instance
91
91
  */
92
92
 
@@ -99,7 +99,7 @@ Object.defineProperty(VirtualOptions.prototype, 'count', opts);
99
99
  * @api public
100
100
  * @property match
101
101
  * @memberOf VirtualOptions
102
- * @type {Object|Function}
102
+ * @type {object|Function}
103
103
  * @instance
104
104
  */
105
105
 
@@ -115,7 +115,7 @@ Object.defineProperty(VirtualOptions.prototype, 'match', opts);
115
115
  * @api public
116
116
  * @property options
117
117
  * @memberOf VirtualOptions
118
- * @type {Object}
118
+ * @type {object}
119
119
  * @instance
120
120
  */
121
121
 
@@ -127,7 +127,7 @@ Object.defineProperty(VirtualOptions.prototype, 'options', opts);
127
127
  * @api public
128
128
  * @property skip
129
129
  * @memberOf VirtualOptions
130
- * @type {Number}
130
+ * @type {number}
131
131
  * @instance
132
132
  */
133
133
 
@@ -139,7 +139,7 @@ Object.defineProperty(VirtualOptions.prototype, 'skip', opts);
139
139
  * @api public
140
140
  * @property limit
141
141
  * @memberOf VirtualOptions
142
- * @type {Number}
142
+ * @type {number}
143
143
  * @instance
144
144
  */
145
145
 
@@ -155,7 +155,7 @@ Object.defineProperty(VirtualOptions.prototype, 'limit', opts);
155
155
  * @api public
156
156
  * @property perDocumentLimit
157
157
  * @memberOf VirtualOptions
158
- * @type {Number}
158
+ * @type {number}
159
159
  * @instance
160
160
  */
161
161
 
@@ -3,4 +3,3 @@
3
3
  exports.saveSubdocs = require('./saveSubdocs');
4
4
  exports.sharding = require('./sharding');
5
5
  exports.trackTransaction = require('./trackTransaction');
6
- exports.validateBeforeSave = require('./validateBeforeSave');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const each = require('../helpers/each');
3
+ const symbols = require('../schema/symbols');
4
4
 
5
5
  /*!
6
6
  * ignore
@@ -8,95 +8,87 @@ const each = require('../helpers/each');
8
8
 
9
9
  module.exports = function saveSubdocs(schema) {
10
10
  const unshift = true;
11
- schema.s.hooks.pre('save', false, function saveSubdocsPreSave(next) {
12
- if (this.$isSubdocument) {
13
- next();
14
- return;
15
- }
16
-
17
- const _this = this;
18
- const subdocs = this.$getAllSubdocs({ useCache: true });
19
-
20
- if (!subdocs.length) {
21
- next();
22
- return;
23
- }
24
-
25
- each(subdocs, function(subdoc, cb) {
26
- subdoc.$__schema.s.hooks.execPre('save', subdoc, function(err) {
27
- cb(err);
28
- });
29
- }, function(error) {
30
- // Invalidate subdocs cache because subdoc pre hooks can add new subdocuments
31
- if (_this.$__.saveOptions) {
32
- _this.$__.saveOptions.__subdocs = null;
33
- }
34
- if (error) {
35
- return _this.$__schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
36
- next(error);
37
- });
38
- }
39
- next();
40
- });
41
- }, null, unshift);
42
-
43
- schema.s.hooks.post('save', async function saveSubdocsPostDeleteOne() {
44
- const removedSubdocs = this.$__.removedSubdocs;
45
- if (!removedSubdocs || !removedSubdocs.length) {
46
- return;
47
- }
48
-
49
- const promises = [];
50
- for (const subdoc of removedSubdocs) {
51
- promises.push(new Promise((resolve, reject) => {
52
- subdoc.$__schema.s.hooks.execPost('deleteOne', subdoc, [subdoc], function(err) {
53
- if (err) {
54
- return reject(err);
55
- }
56
- resolve();
57
- });
58
- }));
59
- }
60
-
61
- this.$__.removedSubdocs = null;
62
- await Promise.all(promises);
63
- });
64
-
65
- schema.s.hooks.post('save', async function saveSubdocsPostSave() {
66
- if (this.$isSubdocument) {
67
- return;
68
- }
69
-
70
- const _this = this;
71
- const subdocs = this.$getAllSubdocs({ useCache: true });
72
-
73
- if (!subdocs.length) {
74
- return;
75
- }
76
-
77
- const promises = [];
78
- for (const subdoc of subdocs) {
79
- promises.push(new Promise((resolve, reject) => {
80
- subdoc.$__schema.s.hooks.execPost('save', subdoc, [subdoc], function(err) {
81
- if (err) {
82
- return reject(err);
83
- }
84
- resolve();
85
- });
86
- }));
87
- }
88
-
89
- try {
90
- await Promise.all(promises);
91
- } catch (error) {
92
- await new Promise((resolve, reject) => {
93
- this.$__schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
94
- if (error) {
95
- return reject(error);
96
- }
97
- resolve();
98
- });
99
- });
100
- }
101
- }, null, unshift);
11
+
12
+ schema.s.hooks.pre('save', false, saveSubdocsPreSave, null, unshift);
13
+ schema.s.hooks.post('save', saveSubdocsPostSave, null, unshift);
14
+ schema.s.hooks.pre('save', saveSubdocsPreDeleteOne);
15
+ schema.s.hooks.post('save', saveSubdocsPostDeleteOne);
102
16
  };
17
+
18
+
19
+ async function saveSubdocsPreSave() {
20
+ if (this.$isSubdocument) {
21
+ return;
22
+ }
23
+
24
+ const subdocs = this.$getAllSubdocs({ useCache: true });
25
+
26
+ if (!subdocs.length) {
27
+ return;
28
+ }
29
+
30
+ const options = this.$__.saveOptions;
31
+ await Promise.all(subdocs.map(subdoc => subdoc._execDocumentPreHooks('save', options, [options])));
32
+
33
+ // Invalidate subdocs cache because subdoc pre hooks can add new subdocuments
34
+ if (this.$__.saveOptions) {
35
+ this.$__.saveOptions.__subdocs = null;
36
+ }
37
+ }
38
+
39
+ async function saveSubdocsPostSave() {
40
+ if (this.$isSubdocument) {
41
+ return;
42
+ }
43
+
44
+ const subdocs = this.$getAllSubdocs({ useCache: true });
45
+
46
+ if (!subdocs.length) {
47
+ return;
48
+ }
49
+
50
+ const options = this.$__.saveOptions;
51
+ const promises = [];
52
+ for (const subdoc of subdocs) {
53
+ promises.push(subdoc._execDocumentPostHooks('save', options));
54
+ }
55
+
56
+ await Promise.all(promises);
57
+ }
58
+
59
+ async function saveSubdocsPreDeleteOne() {
60
+ const removedSubdocs = this.$__.removedSubdocs;
61
+ if (!removedSubdocs?.length) {
62
+ return;
63
+ }
64
+
65
+ const options = this.$__.saveOptions;
66
+ const promises = [];
67
+ for (const subdoc of removedSubdocs) {
68
+ promises.push(subdoc._execDocumentPreHooks('deleteOne', options));
69
+ }
70
+
71
+ await Promise.all(promises);
72
+ }
73
+
74
+ async function saveSubdocsPostDeleteOne() {
75
+ const removedSubdocs = this.$__.removedSubdocs;
76
+ if (!removedSubdocs?.length) {
77
+ return;
78
+ }
79
+
80
+ const options = this.$__.saveOptions;
81
+ const promises = [];
82
+ for (const subdoc of removedSubdocs) {
83
+ promises.push(subdoc._execDocumentPostHooks('deleteOne', options));
84
+ }
85
+
86
+ this.$__.removedSubdocs = null;
87
+ await Promise.all(promises);
88
+ }
89
+
90
+
91
+ saveSubdocsPreSave[symbols.builtInMiddleware] = true;
92
+ saveSubdocsPostSave[symbols.builtInMiddleware] = true;
93
+ saveSubdocsPreDeleteOne[symbols.builtInMiddleware] = true;
94
+ saveSubdocsPostDeleteOne[symbols.builtInMiddleware] = true;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const objectIdSymbol = require('../helpers/symbols').objectIdSymbol;
4
+ const symbols = require('../schema/symbols');
4
5
  const utils = require('../utils');
5
6
 
6
7
  /*!
@@ -8,23 +9,34 @@ const utils = require('../utils');
8
9
  */
9
10
 
10
11
  module.exports = function shardingPlugin(schema) {
11
- schema.post('init', function shardingPluginPostInit() {
12
- storeShard.call(this);
13
- return this;
14
- });
15
- schema.pre('save', function shardingPluginPreSave(next) {
16
- applyWhere.call(this);
17
- next();
18
- });
19
- schema.pre('deleteOne', { document: true, query: false }, function shardingPluginPreRemove(next) {
20
- applyWhere.call(this);
21
- next();
22
- });
23
- schema.post('save', function shardingPluginPostSave() {
24
- storeShard.call(this);
25
- });
12
+ schema.post('init', shardingPluginPostInit);
13
+ schema.pre('save', shardingPluginPreSave);
14
+ schema.post('save', shardingPluginPostSave);
15
+ schema.pre('deleteOne', { document: true, query: false }, shardingPluginPreDeleteOne);
16
+ schema.pre('updateOne', { document: true, query: false }, shardingPluginPreUpdateOne);
26
17
  };
27
18
 
19
+ function shardingPluginPostInit() {
20
+ storeShard.call(this);
21
+ return this;
22
+ }
23
+
24
+ function shardingPluginPreSave() {
25
+ applyWhere.call(this);
26
+ }
27
+
28
+ function shardingPluginPostSave() {
29
+ storeShard.call(this);
30
+ }
31
+
32
+ function shardingPluginPreDeleteOne() {
33
+ applyWhere.call(this);
34
+ }
35
+
36
+ function shardingPluginPreUpdateOne() {
37
+ applyWhere.call(this);
38
+ }
39
+
28
40
  /*!
29
41
  * ignore
30
42
  */
@@ -81,3 +93,9 @@ function storeShard() {
81
93
  }
82
94
  }
83
95
  }
96
+
97
+ shardingPluginPostInit[symbols.builtInMiddleware] = true;
98
+ shardingPluginPreSave[symbols.builtInMiddleware] = true;
99
+ shardingPluginPostSave[symbols.builtInMiddleware] = true;
100
+ shardingPluginPreDeleteOne[symbols.builtInMiddleware] = true;
101
+ shardingPluginPreUpdateOne[symbols.builtInMiddleware] = true;
@@ -2,34 +2,37 @@
2
2
 
3
3
  const arrayAtomicsSymbol = require('../helpers/symbols').arrayAtomicsSymbol;
4
4
  const sessionNewDocuments = require('../helpers/symbols').sessionNewDocuments;
5
+ const symbols = require('../schema/symbols');
5
6
  const utils = require('../utils');
6
7
 
7
8
  module.exports = function trackTransaction(schema) {
8
- schema.pre('save', function trackTransactionPreSave() {
9
- const session = this.$session();
10
- if (session == null) {
11
- return;
9
+ schema.pre('save', trackTransactionPreSave);
10
+ };
11
+
12
+ function trackTransactionPreSave() {
13
+ const session = this.$session();
14
+ if (session == null) {
15
+ return;
16
+ }
17
+ if (session.transaction == null || session[sessionNewDocuments] == null) {
18
+ return;
19
+ }
20
+
21
+ if (!session[sessionNewDocuments].has(this)) {
22
+ const initialState = {};
23
+ if (this.isNew) {
24
+ initialState.isNew = true;
12
25
  }
13
- if (session.transaction == null || session[sessionNewDocuments] == null) {
14
- return;
26
+ if (this.$__schema.options.versionKey) {
27
+ initialState.versionKey = this.get(this.$__schema.options.versionKey);
15
28
  }
16
29
 
17
- if (!session[sessionNewDocuments].has(this)) {
18
- const initialState = {};
19
- if (this.isNew) {
20
- initialState.isNew = true;
21
- }
22
- if (this.$__schema.options.versionKey) {
23
- initialState.versionKey = this.get(this.$__schema.options.versionKey);
24
- }
25
-
26
- initialState.modifiedPaths = new Set(Object.keys(this.$__.activePaths.getStatePaths('modify')));
27
- initialState.atomics = _getAtomics(this);
30
+ initialState.modifiedPaths = new Set(Object.keys(this.$__.activePaths.getStatePaths('modify')));
31
+ initialState.atomics = _getAtomics(this);
28
32
 
29
- session[sessionNewDocuments].set(this, initialState);
30
- }
31
- });
32
- };
33
+ session[sessionNewDocuments].set(this, initialState);
34
+ }
35
+ }
33
36
 
34
37
  function _getAtomics(doc, previous) {
35
38
  const pathToAtomics = new Map();
@@ -39,12 +42,11 @@ function _getAtomics(doc, previous) {
39
42
 
40
43
  for (const path of pathsToCheck) {
41
44
  const val = doc.$__getValue(path);
42
- if (val != null &&
43
- Array.isArray(val) &&
45
+ if (Array.isArray(val) &&
44
46
  utils.isMongooseDocumentArray(val) &&
45
47
  val.length &&
46
48
  val[arrayAtomicsSymbol] != null &&
47
- Object.keys(val[arrayAtomicsSymbol]).length !== 0) {
49
+ utils.hasOwnKeys(val[arrayAtomicsSymbol])) {
48
50
  const existing = previous.get(path) || {};
49
51
  pathToAtomics.set(path, mergeAtomics(existing, val[arrayAtomicsSymbol]));
50
52
  }
@@ -55,7 +57,7 @@ function _getAtomics(doc, previous) {
55
57
  const path = dirt.path;
56
58
 
57
59
  const val = dirt.value;
58
- if (val != null && val[arrayAtomicsSymbol] != null && Object.keys(val[arrayAtomicsSymbol]).length !== 0) {
60
+ if (val?.[arrayAtomicsSymbol] != null && utils.hasOwnKeys(val[arrayAtomicsSymbol])) {
59
61
  const existing = previous.get(path) || {};
60
62
  pathToAtomics.set(path, mergeAtomics(existing, val[arrayAtomicsSymbol]));
61
63
  }
@@ -83,3 +85,5 @@ function mergeAtomics(destination, source) {
83
85
 
84
86
  return destination;
85
87
  }
88
+
89
+ trackTransactionPreSave[symbols.builtInMiddleware] = true;