@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.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{Db4IAypj.js → 0J_bLG6U.js} +1 -1
- package/.output/public/_nuxt/{Y39o1QEi.js → 5KLjKHc1.js} +1 -1
- package/.output/public/_nuxt/{B4zoPYF-.js → B2UrsJHg.js} +1 -1
- package/.output/public/_nuxt/{BSqjh6Vk.js → BC5hGokz.js} +1 -1
- package/.output/public/_nuxt/{BS4yU4O0.js → BJwN20Xm.js} +1 -1
- package/.output/public/_nuxt/{D8_n84hl.js → BMgDPqps.js} +1 -1
- package/.output/public/_nuxt/{CqNsQbt9.js → B_sGF2qN.js} +1 -1
- package/.output/public/_nuxt/{NAqlztEN.js → BeaJ7I-K.js} +10 -10
- package/.output/public/_nuxt/{WZ0WK9cR.js → BkE1sm_1.js} +1 -1
- package/.output/public/_nuxt/{kBtP64Rx.js → CADbZwE5.js} +1 -1
- package/.output/public/_nuxt/{B8qGaxNm.js → CB0WRoVi.js} +1 -1
- package/.output/public/_nuxt/{BV6uALfO.js → CCh0PVV0.js} +1 -1
- package/.output/public/_nuxt/{CP9Z7-_9.js → Cr0GW7rA.js} +1 -1
- package/.output/public/_nuxt/{DeCqoVOS.js → DJe7Wxdv.js} +1 -1
- package/.output/public/_nuxt/{dBZQW7JD.js → DRBrUaE5.js} +1 -1
- package/.output/public/_nuxt/{Db19R32y.js → DV2n9B6m.js} +1 -1
- package/.output/public/_nuxt/{CvnpbYw0.js → DVD-jGiv.js} +1 -1
- package/.output/public/_nuxt/{BWajNATZ.js → Dk9qGA5X.js} +3 -3
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/dc761332-547d-4953-b51d-b2d453009b48.json +1 -0
- package/.output/public/_nuxt/error-404.64pZEiDn.css +1 -0
- package/.output/public/_nuxt/error-500.DHOpI0Ir.css +1 -0
- package/.output/public/_nuxt/{BoHhCIKW.js → koEZfutw.js} +3 -3
- package/.output/public/_nuxt/{B_782F4p.js → r6LdR7DN.js} +1 -1
- package/.output/public/_nuxt/{BEI71c6K.js → rEfOp38p.js} +1 -1
- package/.output/server/chunks/_/error-500.mjs.map +1 -1
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{error-404-8tbBXju4.mjs → error-404-BN-7rNE4.mjs} +4 -4
- package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +8 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +1 -0
- package/.output/server/chunks/build/{error-500-DxFsom1i.mjs → error-500-DhIQ-2yt.mjs} +4 -4
- package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +1 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +8 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +1 -0
- package/.output/server/chunks/build/{index-BB-Clavm.mjs → index-Dnrh1ePF.mjs} +1 -1
- package/.output/server/chunks/build/index-Dnrh1ePF.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +9 -9
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/nitro/nitro.mjs +333 -333
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
- package/.output/server/node_modules/bson/package.json +9 -11
- package/.output/server/node_modules/kareem/index.js +228 -343
- package/.output/server/node_modules/kareem/package.json +3 -3
- package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
- package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
- package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
- package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
- package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
- package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
- package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
- package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
- package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
- package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
- package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
- package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
- package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
- package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
- package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
- package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
- package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
- package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
- package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
- package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
- package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
- package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
- package/.output/server/node_modules/mongodb/lib/db.js +6 -7
- package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
- package/.output/server/node_modules/mongodb/lib/error.js +7 -10
- package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
- package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
- package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
- package/.output/server/node_modules/mongodb/lib/index.js +2 -4
- package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
- package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
- package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
- package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
- package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
- package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
- package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
- package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
- package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
- package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
- package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
- package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
- package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
- package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
- package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
- package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
- package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
- package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
- package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
- package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
- package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
- package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
- package/.output/server/node_modules/mongodb/package.json +49 -45
- package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
- package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
- package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
- package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
- package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
- package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
- package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
- package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
- package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
- package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
- package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
- package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
- package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
- package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
- package/.output/server/node_modules/mongoose/lib/document.js +712 -531
- package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
- package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
- package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
- package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
- package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
- package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
- package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
- package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
- package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
- package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
- package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
- package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
- package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
- package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
- package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
- package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
- package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
- package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
- package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
- package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
- package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
- package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
- package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
- package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
- package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
- package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
- package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
- package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
- package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
- package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
- package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
- package/.output/server/node_modules/mongoose/lib/model.js +940 -946
- package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
- package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
- package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
- package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
- package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
- package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
- package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
- package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
- package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
- package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
- package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
- package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
- package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
- package/.output/server/node_modules/mongoose/lib/query.js +700 -548
- package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
- package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
- package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
- package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
- package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
- package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
- package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
- package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
- package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
- package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
- package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
- package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
- package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
- package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
- package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
- package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
- package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
- package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
- package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
- package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
- package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
- package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
- package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
- package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
- package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
- package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
- package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
- package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
- package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
- package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
- package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
- package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
- package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
- package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
- package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
- package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
- package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
- package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
- package/.output/server/node_modules/mongoose/package.json +46 -63
- package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
- package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
- package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
- package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
- package/.output/server/node_modules/mquery/package.json +4 -7
- package/.output/server/package.json +7 -9
- package/package.json +3 -3
- package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
- package/.output/public/_nuxt/error-404.CTWLHxjC.css +0 -1
- package/.output/public/_nuxt/error-500.UBfk8-QP.css +0 -1
- package/.output/server/chunks/build/error-404-8tbBXju4.mjs.map +0 -1
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs +0 -8
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-DxFsom1i.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs +0 -8
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs.map +0 -1
- package/.output/server/chunks/build/index-BB-Clavm.mjs.map +0 -1
- package/.output/server/node_modules/debug/package.json +0 -64
- package/.output/server/node_modules/debug/src/browser.js +0 -272
- package/.output/server/node_modules/debug/src/common.js +0 -292
- package/.output/server/node_modules/debug/src/index.js +0 -10
- package/.output/server/node_modules/debug/src/node.js +0 -263
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
- package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
- package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
- package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
- package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
- package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
- package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
- package/.output/server/node_modules/supports-color/index.js +0 -202
- package/.output/server/node_modules/supports-color/package.json +0 -64
|
@@ -4,28 +4,27 @@ const get = require('./get');
|
|
|
4
4
|
/**
|
|
5
5
|
* Applies defaults to update and findOneAndUpdate operations.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {object} filter
|
|
8
8
|
* @param {Schema} schema
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
9
|
+
* @param {object} castedDoc
|
|
10
|
+
* @param {object} options
|
|
11
|
+
* @param {object} queryMongooseOptions
|
|
12
|
+
* @param {object | null} [context] the context to pass to default functions as `this`
|
|
11
13
|
* @method setDefaultsOnInsert
|
|
12
14
|
* @api private
|
|
13
15
|
*/
|
|
14
16
|
|
|
15
|
-
module.exports = function(filter, schema, castedDoc, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options.setDefaultsOnInsert != null ?
|
|
20
|
-
options.setDefaultsOnInsert :
|
|
21
|
-
schema.base.options.setDefaultsOnInsert;
|
|
17
|
+
module.exports = function(filter, schema, castedDoc, options, queryMongooseOptions, context) {
|
|
18
|
+
const shouldSetDefaultsOnInsert = options?.setDefaultsOnInsert ??
|
|
19
|
+
queryMongooseOptions?.setDefaultsOnInsert ??
|
|
20
|
+
schema.base.options.setDefaultsOnInsert;
|
|
22
21
|
|
|
23
22
|
if (!options.upsert || shouldSetDefaultsOnInsert === false) {
|
|
24
23
|
return castedDoc;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
const keys = Object.keys(castedDoc || {});
|
|
28
|
-
const updatedKeys =
|
|
27
|
+
const updatedKeys = Object.create(null);
|
|
29
28
|
const updatedValues = {};
|
|
30
29
|
const numKeys = keys.length;
|
|
31
30
|
|
|
@@ -58,9 +57,23 @@ module.exports = function(filter, schema, castedDoc, options) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
updatedKeys[path] = true;
|
|
60
|
+
if (path.indexOf('.') === -1) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Also mark all parent prefixes so child-path lookups are O(1).
|
|
64
|
+
// e.g. 'extraProps.location' also marks 'extraProps'
|
|
65
|
+
const pieces = schema.paths[path] ?
|
|
66
|
+
// If the SchemaType already split for us, use that to avoid the extra overhead
|
|
67
|
+
schema.paths[path].splitPath() :
|
|
68
|
+
path.split('.');
|
|
69
|
+
let cur = pieces[0];
|
|
70
|
+
for (let j = 1; j < pieces.length; ++j) {
|
|
71
|
+
updatedKeys[cur] = true;
|
|
72
|
+
cur += '.' + pieces[j];
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
if (options
|
|
76
|
+
if (options?.overwrite && !hasDollarUpdate) {
|
|
64
77
|
// Defaults will be set later, since we're overwriting we'll cast
|
|
65
78
|
// the whole update to a document
|
|
66
79
|
return castedDoc;
|
|
@@ -71,7 +84,7 @@ module.exports = function(filter, schema, castedDoc, options) {
|
|
|
71
84
|
if (schemaType.path === '_id' && schemaType.options.auto) {
|
|
72
85
|
return;
|
|
73
86
|
}
|
|
74
|
-
const def = schemaType.getDefault(null, true);
|
|
87
|
+
const def = schemaType.getDefault(null, true, { context });
|
|
75
88
|
if (typeof def === 'undefined') {
|
|
76
89
|
return;
|
|
77
90
|
}
|
package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = function setDocumentTimestamps(doc, timestampOption, currentTime, createdAt, updatedAt) {
|
|
4
|
-
const skipUpdatedAt = timestampOption
|
|
5
|
-
const skipCreatedAt = timestampOption
|
|
4
|
+
const skipUpdatedAt = timestampOption?.updatedAt === false;
|
|
5
|
+
const skipCreatedAt = timestampOption?.createdAt === false;
|
|
6
6
|
|
|
7
7
|
const defaultTimestamp = currentTime != null ?
|
|
8
8
|
currentTime() :
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const applyTimestampsToChildren = require('../update/applyTimestampsToChildren');
|
|
4
4
|
const applyTimestampsToUpdate = require('../update/applyTimestampsToUpdate');
|
|
5
|
-
const get = require('../get');
|
|
6
5
|
const handleTimestampOption = require('../schema/handleTimestampOption');
|
|
7
6
|
const setDocumentTimestamps = require('./setDocumentTimestamps');
|
|
8
7
|
const symbols = require('../../schema/symbols');
|
|
@@ -31,8 +30,8 @@ module.exports = function setupTimestamps(schema, timestamps) {
|
|
|
31
30
|
schema.$timestamps = { createdAt: createdAt, updatedAt: updatedAt };
|
|
32
31
|
|
|
33
32
|
if (createdAt && !schema.paths[createdAt]) {
|
|
34
|
-
const baseImmutableCreatedAt = schema.base
|
|
35
|
-
const immutable = baseImmutableCreatedAt
|
|
33
|
+
const baseImmutableCreatedAt = schema.base?.get('timestamps.createdAt.immutable') ?? null;
|
|
34
|
+
const immutable = baseImmutableCreatedAt ?? true;
|
|
36
35
|
schemaAdditions[createdAt] = { [schema.options.typeKey || 'type']: Date, immutable };
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -42,26 +41,26 @@ module.exports = function setupTimestamps(schema, timestamps) {
|
|
|
42
41
|
|
|
43
42
|
schema.add(schemaAdditions);
|
|
44
43
|
|
|
45
|
-
schema.pre('save',
|
|
46
|
-
const timestampOption = get(this, '$__.saveOptions.timestamps');
|
|
47
|
-
if (timestampOption === false) {
|
|
48
|
-
return next();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setDocumentTimestamps(this, timestampOption, currentTime, createdAt, updatedAt);
|
|
52
|
-
|
|
53
|
-
next();
|
|
54
|
-
});
|
|
44
|
+
schema.pre('save', timestampsPreSave);
|
|
55
45
|
|
|
56
|
-
schema.methods.initializeTimestamps = function() {
|
|
46
|
+
schema.methods.initializeTimestamps = function(timestampsOptions) {
|
|
47
|
+
if (timestampsOptions === false) {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
57
50
|
const ts = currentTime != null ?
|
|
58
51
|
currentTime() : this.constructor.base.now();
|
|
59
52
|
|
|
53
|
+
const initTimestampsCreatedAt = timestampsOptions != null ?
|
|
54
|
+
handleTimestampOption(timestampsOptions, 'createdAt') :
|
|
55
|
+
createdAt;
|
|
56
|
+
const initTimestampsUpdatedAt = timestampsOptions != null ?
|
|
57
|
+
handleTimestampOption(timestampsOptions, 'updatedAt') :
|
|
58
|
+
updatedAt;
|
|
60
59
|
|
|
61
|
-
if (
|
|
60
|
+
if (initTimestampsCreatedAt && !this.get(initTimestampsCreatedAt)) {
|
|
62
61
|
this.$set(createdAt, ts);
|
|
63
62
|
}
|
|
64
|
-
if (
|
|
63
|
+
if (initTimestampsUpdatedAt && !this.get(initTimestampsUpdatedAt)) {
|
|
65
64
|
this.$set(updatedAt, ts);
|
|
66
65
|
}
|
|
67
66
|
if (this.$isSubdocument) {
|
|
@@ -71,15 +70,13 @@ module.exports = function setupTimestamps(schema, timestamps) {
|
|
|
71
70
|
const subdocs = this.$getAllSubdocs();
|
|
72
71
|
for (const subdoc of subdocs) {
|
|
73
72
|
if (subdoc.initializeTimestamps) {
|
|
74
|
-
subdoc.initializeTimestamps();
|
|
73
|
+
subdoc.initializeTimestamps(timestampsOptions);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
return this;
|
|
79
78
|
};
|
|
80
79
|
|
|
81
|
-
_setTimestampsOnUpdate[symbols.builtInMiddleware] = true;
|
|
82
|
-
|
|
83
80
|
const opts = { query: true, model: false };
|
|
84
81
|
schema.pre('findOneAndReplace', opts, _setTimestampsOnUpdate);
|
|
85
82
|
schema.pre('findOneAndUpdate', opts, _setTimestampsOnUpdate);
|
|
@@ -87,24 +84,49 @@ module.exports = function setupTimestamps(schema, timestamps) {
|
|
|
87
84
|
schema.pre('update', opts, _setTimestampsOnUpdate);
|
|
88
85
|
schema.pre('updateOne', opts, _setTimestampsOnUpdate);
|
|
89
86
|
schema.pre('updateMany', opts, _setTimestampsOnUpdate);
|
|
87
|
+
};
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// Replacing with null update should still trigger timestamps
|
|
96
|
-
if (replaceOps.has(this.op) && this.getUpdate() == null) {
|
|
97
|
-
this.setUpdate({});
|
|
98
|
-
}
|
|
99
|
-
applyTimestampsToUpdate(
|
|
100
|
-
now,
|
|
101
|
-
createdAt,
|
|
102
|
-
updatedAt,
|
|
103
|
-
this.getUpdate(),
|
|
104
|
-
this._mongooseOptions,
|
|
105
|
-
replaceOps.has(this.op)
|
|
106
|
-
);
|
|
107
|
-
applyTimestampsToChildren(now, this.getUpdate(), this.model.schema);
|
|
108
|
-
next();
|
|
89
|
+
function timestampsPreSave() {
|
|
90
|
+
const timestampOption = this.$__?.saveOptions?.timestamps;
|
|
91
|
+
if (timestampOption === false) {
|
|
92
|
+
return;
|
|
109
93
|
}
|
|
110
|
-
|
|
94
|
+
|
|
95
|
+
const schema = this.$__schema;
|
|
96
|
+
const { createdAt, updatedAt } = schema.$timestamps;
|
|
97
|
+
const timestamps = schema.options.timestamps;
|
|
98
|
+
const currentTime = timestamps != null && Object.hasOwn(timestamps, 'currentTime') ?
|
|
99
|
+
timestamps.currentTime :
|
|
100
|
+
null;
|
|
101
|
+
|
|
102
|
+
setDocumentTimestamps(this, timestampOption, currentTime, createdAt, updatedAt);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function _setTimestampsOnUpdate() {
|
|
106
|
+
const schema = this.model.schema;
|
|
107
|
+
const { createdAt, updatedAt } = schema.$timestamps;
|
|
108
|
+
const timestamps = schema.options.timestamps;
|
|
109
|
+
const currentTime = timestamps != null && Object.hasOwn(timestamps, 'currentTime') ?
|
|
110
|
+
timestamps.currentTime :
|
|
111
|
+
null;
|
|
112
|
+
|
|
113
|
+
const now = currentTime != null ?
|
|
114
|
+
currentTime() :
|
|
115
|
+
this.model.base.now();
|
|
116
|
+
// Replacing with null update should still trigger timestamps
|
|
117
|
+
if (replaceOps.has(this.op) && this.getUpdate() == null) {
|
|
118
|
+
this.setUpdate({});
|
|
119
|
+
}
|
|
120
|
+
applyTimestampsToUpdate(
|
|
121
|
+
now,
|
|
122
|
+
createdAt,
|
|
123
|
+
updatedAt,
|
|
124
|
+
this.getUpdate(),
|
|
125
|
+
this._mongooseOptions,
|
|
126
|
+
replaceOps.has(this.op)
|
|
127
|
+
);
|
|
128
|
+
applyTimestampsToChildren(now, this.getUpdate(), this.model.schema);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
timestampsPreSave[symbols.builtInMiddleware] = true;
|
|
132
|
+
_setTimestampsOnUpdate[symbols.builtInMiddleware] = true;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const get = require('../get');
|
|
8
|
+
const utils = require('../../utils');
|
|
8
9
|
|
|
9
10
|
module.exports = applyTimestampsToUpdate;
|
|
10
11
|
|
|
@@ -22,11 +23,11 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
22
23
|
return currentUpdate;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const skipCreatedAt = timestamps
|
|
26
|
-
const skipUpdatedAt = timestamps
|
|
26
|
+
const skipCreatedAt = timestamps?.createdAt === false;
|
|
27
|
+
const skipUpdatedAt = timestamps?.updatedAt === false;
|
|
27
28
|
|
|
28
29
|
if (isReplace) {
|
|
29
|
-
if (currentUpdate
|
|
30
|
+
if (currentUpdate?.$set) {
|
|
30
31
|
currentUpdate = currentUpdate.$set;
|
|
31
32
|
updates.$set = {};
|
|
32
33
|
_updates = updates.$set;
|
|
@@ -51,7 +52,7 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
51
52
|
}
|
|
52
53
|
updates.$set = updates.$set || {};
|
|
53
54
|
if (!skipUpdatedAt && updatedAt &&
|
|
54
|
-
|
|
55
|
+
!currentUpdate.$currentDate?.[updatedAt]) {
|
|
55
56
|
let timestampSet = false;
|
|
56
57
|
if (updatedAt.indexOf('.') !== -1) {
|
|
57
58
|
const pieces = updatedAt.split('.');
|
|
@@ -62,7 +63,7 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
62
63
|
currentUpdate[start][remnant] = now;
|
|
63
64
|
timestampSet = true;
|
|
64
65
|
break;
|
|
65
|
-
} else if (currentUpdate.$set
|
|
66
|
+
} else if (currentUpdate.$set?.[start]) {
|
|
66
67
|
currentUpdate.$set[start][remnant] = now;
|
|
67
68
|
timestampSet = true;
|
|
68
69
|
break;
|
|
@@ -81,7 +82,9 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
81
82
|
|
|
82
83
|
if (!skipCreatedAt && createdAt) {
|
|
83
84
|
const overwriteImmutable = get(options, 'overwriteImmutable', false);
|
|
84
|
-
const hasUserCreatedAt = currentUpdate[createdAt] != null
|
|
85
|
+
const hasUserCreatedAt = currentUpdate[createdAt] != null
|
|
86
|
+
|| currentUpdate.$set?.[createdAt] != null
|
|
87
|
+
|| currentUpdate.$setOnInsert?.[createdAt] != null;
|
|
85
88
|
|
|
86
89
|
// If overwriteImmutable is true and user provided createdAt, keep their value
|
|
87
90
|
if (overwriteImmutable && hasUserCreatedAt) {
|
|
@@ -90,12 +93,12 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
90
93
|
updates.$set[createdAt] = currentUpdate[createdAt];
|
|
91
94
|
delete currentUpdate[createdAt];
|
|
92
95
|
}
|
|
93
|
-
// User's value is already in $set, nothing more to do
|
|
96
|
+
// User's value is already in $set or $setOnInsert, nothing more to do
|
|
94
97
|
} else {
|
|
95
98
|
if (currentUpdate[createdAt]) {
|
|
96
99
|
delete currentUpdate[createdAt];
|
|
97
100
|
}
|
|
98
|
-
if (currentUpdate.$set
|
|
101
|
+
if (currentUpdate.$set?.[createdAt]) {
|
|
99
102
|
delete currentUpdate.$set[createdAt];
|
|
100
103
|
}
|
|
101
104
|
let timestampSet = false;
|
|
@@ -108,7 +111,7 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
108
111
|
currentUpdate[start][remnant] = now;
|
|
109
112
|
timestampSet = true;
|
|
110
113
|
break;
|
|
111
|
-
} else if (currentUpdate.$set
|
|
114
|
+
} else if (currentUpdate.$set?.[start]) {
|
|
112
115
|
currentUpdate.$set[start][remnant] = now;
|
|
113
116
|
timestampSet = true;
|
|
114
117
|
break;
|
|
@@ -123,7 +126,7 @@ function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, optio
|
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
if (
|
|
129
|
+
if (utils.hasOwnKeys(updates.$set) === false) {
|
|
127
130
|
delete updates.$set;
|
|
128
131
|
}
|
|
129
132
|
return updates;
|
|
@@ -4,6 +4,7 @@ const castFilterPath = require('../query/castFilterPath');
|
|
|
4
4
|
const cleanPositionalOperators = require('../schema/cleanPositionalOperators');
|
|
5
5
|
const getPath = require('../schema/getPath');
|
|
6
6
|
const updatedPathsByArrayFilter = require('./updatedPathsByArrayFilter');
|
|
7
|
+
const utils = require('../../utils');
|
|
7
8
|
|
|
8
9
|
module.exports = function castArrayFilters(query) {
|
|
9
10
|
const arrayFilters = query.options.arrayFilters;
|
|
@@ -18,7 +19,7 @@ module.exports = function castArrayFilters(query) {
|
|
|
18
19
|
if (query._mongooseOptions.strict != null) {
|
|
19
20
|
strictQuery = query._mongooseOptions.strict;
|
|
20
21
|
}
|
|
21
|
-
if (query.model
|
|
22
|
+
if (query.model?.base.options.strictQuery != null) {
|
|
22
23
|
strictQuery = query.model.base.options.strictQuery;
|
|
23
24
|
}
|
|
24
25
|
if (schema._userProvidedOptions.strictQuery != null) {
|
|
@@ -63,8 +64,7 @@ function _castArrayFilters(arrayFilters, schema, strictQuery, updatedPathsByFilt
|
|
|
63
64
|
|
|
64
65
|
const baseSchematype = getPath(schema, baseFilterPath, discriminatorValueMap);
|
|
65
66
|
let filterBaseSchema = baseSchematype != null ? baseSchematype.schema : null;
|
|
66
|
-
if (filterBaseSchema != null &&
|
|
67
|
-
filterBaseSchema.discriminators != null &&
|
|
67
|
+
if (filterBaseSchema?.discriminators != null &&
|
|
68
68
|
filter[filterWildcardPath + '.' + filterBaseSchema.options.discriminatorKey]) {
|
|
69
69
|
filterBaseSchema = filterBaseSchema.discriminators[filter[filterWildcardPath + '.' + filterBaseSchema.options.discriminatorKey]] || filterBaseSchema;
|
|
70
70
|
discriminatorValueMap[baseFilterPath] = filter[filterWildcardPath + '.' + filterBaseSchema.options.discriminatorKey];
|
|
@@ -74,7 +74,7 @@ function _castArrayFilters(arrayFilters, schema, strictQuery, updatedPathsByFilt
|
|
|
74
74
|
if (updatedPathsByFilter[key] === null) {
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
77
|
+
if (utils.hasOwnKeys(updatedPathsByFilter) === false) {
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
const dot = key.indexOf('.');
|
|
@@ -10,8 +10,8 @@ const _modifiedPaths = require('../common').modifiedPaths;
|
|
|
10
10
|
* will get wrapped in a `$set`. The Mongoose Query is responsible for wrapping
|
|
11
11
|
* top-level keys in `$set`.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @return {
|
|
13
|
+
* @param {object} update
|
|
14
|
+
* @return {object} modified
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
module.exports = function modifiedPaths(update) {
|
|
@@ -6,11 +6,16 @@
|
|
|
6
6
|
* filters.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
module.exports = function removeUnusedArrayFilters(update,
|
|
9
|
+
module.exports = function removeUnusedArrayFilters(update, options) {
|
|
10
|
+
const arrayFilters = options?.arrayFilters;
|
|
11
|
+
if (!Array.isArray(arrayFilters)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const updateKeys = Object.keys(update).
|
|
11
16
|
map(key => Object.keys(update[key])).
|
|
12
17
|
reduce((cur, arr) => cur.concat(arr), []);
|
|
13
|
-
|
|
18
|
+
options.arrayFilters = options.arrayFilters.filter(obj => {
|
|
14
19
|
return _checkSingleFilterKey(obj, updateKeys);
|
|
15
20
|
});
|
|
16
21
|
};
|
|
@@ -14,13 +14,13 @@ const flatten = require('./common').flatten;
|
|
|
14
14
|
*
|
|
15
15
|
* @param {Query} query
|
|
16
16
|
* @param {Schema} schema
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
17
|
+
* @param {object} castedDoc
|
|
18
|
+
* @param {object} options
|
|
19
19
|
* @method runValidatorsOnUpdate
|
|
20
20
|
* @api private
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
module.exports = function(query, schema, castedDoc, options
|
|
23
|
+
module.exports = async function updateValidators(query, schema, castedDoc, options) {
|
|
24
24
|
const keys = Object.keys(castedDoc || {});
|
|
25
25
|
let updatedKeys = {};
|
|
26
26
|
let updatedValues = {};
|
|
@@ -30,16 +30,15 @@ module.exports = function(query, schema, castedDoc, options, callback) {
|
|
|
30
30
|
let hasDollarUpdate = false;
|
|
31
31
|
let currentUpdate;
|
|
32
32
|
let key;
|
|
33
|
-
let i;
|
|
34
33
|
|
|
35
|
-
for (i = 0; i < numKeys; ++i) {
|
|
34
|
+
for (let i = 0; i < numKeys; ++i) {
|
|
36
35
|
if (keys[i].startsWith('$')) {
|
|
37
36
|
hasDollarUpdate = true;
|
|
38
37
|
if (keys[i] === '$push' || keys[i] === '$addToSet') {
|
|
39
38
|
const _keys = Object.keys(castedDoc[keys[i]]);
|
|
40
39
|
for (let ii = 0; ii < _keys.length; ++ii) {
|
|
41
40
|
currentUpdate = castedDoc[keys[i]][_keys[ii]];
|
|
42
|
-
if (currentUpdate
|
|
41
|
+
if (currentUpdate?.$each) {
|
|
43
42
|
arrayAtomicUpdates[_keys[ii]] = (arrayAtomicUpdates[_keys[ii]] || []).
|
|
44
43
|
concat(currentUpdate.$each);
|
|
45
44
|
} else {
|
|
@@ -85,163 +84,103 @@ module.exports = function(query, schema, castedDoc, options, callback) {
|
|
|
85
84
|
const alreadyValidated = [];
|
|
86
85
|
|
|
87
86
|
const context = query;
|
|
88
|
-
|
|
87
|
+
for (let i = 0; i < numUpdates; ++i) {
|
|
88
|
+
const v = updatedValues[updates[i]];
|
|
89
89
|
const schemaPath = schema._getSchema(updates[i]);
|
|
90
90
|
if (schemaPath == null) {
|
|
91
|
-
|
|
91
|
+
continue;
|
|
92
92
|
}
|
|
93
93
|
if (schemaPath.instance === 'Mixed' && schemaPath.path !== updates[i]) {
|
|
94
|
-
|
|
94
|
+
continue;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (v && Array.isArray(v.$in)) {
|
|
98
98
|
v.$in.forEach((v, i) => {
|
|
99
|
-
validatorsToExecute.push(
|
|
100
|
-
schemaPath.doValidate(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
validationErrors.push(err);
|
|
106
|
-
}
|
|
107
|
-
callback(null);
|
|
108
|
-
},
|
|
109
|
-
context,
|
|
110
|
-
{ updateValidator: true });
|
|
111
|
-
});
|
|
99
|
+
validatorsToExecute.push(
|
|
100
|
+
schemaPath.doValidate(v, context, { updateValidator: true }).catch(err => {
|
|
101
|
+
err.path = updates[i] + '.$in.' + i;
|
|
102
|
+
validationErrors.push(err);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
112
105
|
});
|
|
113
106
|
} else {
|
|
114
107
|
if (isPull[updates[i]] &&
|
|
115
108
|
schemaPath.$isMongooseArray) {
|
|
116
|
-
|
|
109
|
+
continue;
|
|
117
110
|
}
|
|
118
111
|
|
|
119
|
-
if (schemaPath.$isMongooseDocumentArrayElement && v
|
|
112
|
+
if (schemaPath.$isMongooseDocumentArrayElement && v?.$__ != null) {
|
|
120
113
|
alreadyValidated.push(updates[i]);
|
|
121
|
-
validatorsToExecute.push(
|
|
122
|
-
schemaPath.doValidate(v,
|
|
123
|
-
if (err) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
validationErrors.push(_err);
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
err.path = updates[i];
|
|
132
|
-
validationErrors.push(err);
|
|
114
|
+
validatorsToExecute.push(
|
|
115
|
+
schemaPath.doValidate(v, context, { updateValidator: true }).catch(err => {
|
|
116
|
+
if (err.errors) {
|
|
117
|
+
for (const key of Object.keys(err.errors)) {
|
|
118
|
+
const _err = err.errors[key];
|
|
119
|
+
_err.path = updates[i] + '.' + key;
|
|
120
|
+
validationErrors.push(_err);
|
|
133
121
|
}
|
|
122
|
+
} else {
|
|
123
|
+
err.path = updates[i];
|
|
124
|
+
validationErrors.push(err);
|
|
134
125
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}, context, { updateValidator: true });
|
|
138
|
-
});
|
|
126
|
+
})
|
|
127
|
+
);
|
|
139
128
|
} else {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
schemaPath.doValidate(v, function(err) {
|
|
129
|
+
const isAlreadyValidated = alreadyValidated.find(path => updates[i].startsWith(path + '.'));
|
|
130
|
+
if (isAlreadyValidated) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (schemaPath.$isSingleNested) {
|
|
134
|
+
alreadyValidated.push(updates[i]);
|
|
135
|
+
}
|
|
136
|
+
validatorsToExecute.push(
|
|
137
|
+
schemaPath.doValidate(v, context, { updateValidator: true }).catch(err => {
|
|
151
138
|
if (schemaPath.schema != null &&
|
|
152
139
|
schemaPath.schema.options.storeSubdocValidationError === false &&
|
|
153
140
|
err instanceof ValidationError) {
|
|
154
|
-
return
|
|
141
|
+
return;
|
|
155
142
|
}
|
|
156
143
|
|
|
157
144
|
if (err) {
|
|
158
145
|
err.path = updates[i];
|
|
159
146
|
validationErrors.push(err);
|
|
160
147
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
148
|
+
})
|
|
149
|
+
);
|
|
164
150
|
}
|
|
165
151
|
}
|
|
166
152
|
}
|
|
167
|
-
for (i = 0; i < numUpdates; ++i) {
|
|
168
|
-
iter(i, updatedValues[updates[i]]);
|
|
169
|
-
}
|
|
170
153
|
|
|
171
154
|
const arrayUpdates = Object.keys(arrayAtomicUpdates);
|
|
172
155
|
for (const arrayUpdate of arrayUpdates) {
|
|
173
156
|
let schemaPath = schema._getSchema(arrayUpdate);
|
|
174
157
|
if (schemaPath && schemaPath.$isMongooseDocumentArray) {
|
|
175
|
-
validatorsToExecute.push(
|
|
158
|
+
validatorsToExecute.push(
|
|
176
159
|
schemaPath.doValidate(
|
|
177
160
|
arrayAtomicUpdates[arrayUpdate],
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
161
|
+
options?.context === 'query' ? query : null
|
|
162
|
+
).catch(err => {
|
|
163
|
+
err.path = arrayUpdate;
|
|
164
|
+
validationErrors.push(err);
|
|
165
|
+
})
|
|
166
|
+
);
|
|
181
167
|
} else {
|
|
182
168
|
schemaPath = schema._getSchema(arrayUpdate + '.0');
|
|
183
169
|
for (const atomicUpdate of arrayAtomicUpdates[arrayUpdate]) {
|
|
184
|
-
validatorsToExecute.push(
|
|
170
|
+
validatorsToExecute.push(
|
|
185
171
|
schemaPath.doValidate(
|
|
186
172
|
atomicUpdate,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (callback != null) {
|
|
196
|
-
let numValidators = validatorsToExecute.length;
|
|
197
|
-
if (numValidators === 0) {
|
|
198
|
-
return _done(callback);
|
|
199
|
-
}
|
|
200
|
-
for (const validator of validatorsToExecute) {
|
|
201
|
-
validator(function() {
|
|
202
|
-
if (--numValidators <= 0) {
|
|
203
|
-
_done(callback);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return function(callback) {
|
|
212
|
-
let numValidators = validatorsToExecute.length;
|
|
213
|
-
if (numValidators === 0) {
|
|
214
|
-
return _done(callback);
|
|
215
|
-
}
|
|
216
|
-
for (const validator of validatorsToExecute) {
|
|
217
|
-
validator(function() {
|
|
218
|
-
if (--numValidators <= 0) {
|
|
219
|
-
_done(callback);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
function _done(callback) {
|
|
226
|
-
if (validationErrors.length) {
|
|
227
|
-
const err = new ValidationError(null);
|
|
228
|
-
|
|
229
|
-
for (const validationError of validationErrors) {
|
|
230
|
-
err.addError(validationError.path, validationError);
|
|
173
|
+
options?.context === 'query' ? query : null,
|
|
174
|
+
{ updateValidator: true }
|
|
175
|
+
).catch(err => {
|
|
176
|
+
err.path = arrayUpdate;
|
|
177
|
+
validationErrors.push(err);
|
|
178
|
+
})
|
|
179
|
+
);
|
|
231
180
|
}
|
|
232
|
-
|
|
233
|
-
return callback(err);
|
|
234
181
|
}
|
|
235
|
-
callback(null);
|
|
236
182
|
}
|
|
237
183
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (err) {
|
|
241
|
-
err.path = arrayUpdate;
|
|
242
|
-
validationErrors.push(err);
|
|
243
|
-
}
|
|
244
|
-
callback(null);
|
|
245
|
-
};
|
|
246
|
-
}
|
|
184
|
+
await Promise.all(validatorsToExecute);
|
|
185
|
+
return validationErrors;
|
|
247
186
|
};
|