@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
|
@@ -12,7 +12,6 @@ const clone = require('./helpers/clone');
|
|
|
12
12
|
const handleImmutable = require('./helpers/schematype/handleImmutable');
|
|
13
13
|
const isAsyncFunction = require('./helpers/isAsyncFunction');
|
|
14
14
|
const isSimpleValidator = require('./helpers/isSimpleValidator');
|
|
15
|
-
const immediate = require('./helpers/immediate');
|
|
16
15
|
const schemaTypeSymbol = require('./helpers/symbols').schemaTypeSymbol;
|
|
17
16
|
const utils = require('./utils');
|
|
18
17
|
const validatorErrorSymbol = require('./helpers/symbols').validatorErrorSymbol;
|
|
@@ -34,9 +33,9 @@ const setOptionsForDefaults = { _skipMarkModified: true };
|
|
|
34
33
|
* const schema = new Schema({ name: String });
|
|
35
34
|
* schema.path('name') instanceof SchemaType; // true
|
|
36
35
|
*
|
|
37
|
-
* @param {
|
|
36
|
+
* @param {string} path
|
|
38
37
|
* @param {SchemaTypeOptions} [options] See [SchemaTypeOptions docs](https://mongoosejs.com/docs/api/schematypeoptions.html)
|
|
39
|
-
* @param {
|
|
38
|
+
* @param {string} [instance]
|
|
40
39
|
* @param {Schema} [parentSchema]
|
|
41
40
|
* @api public
|
|
42
41
|
*/
|
|
@@ -100,11 +99,11 @@ function SchemaType(path, options, instance, parentSchema) {
|
|
|
100
99
|
const index = this._index;
|
|
101
100
|
if (typeof index === 'object' && index != null) {
|
|
102
101
|
if (index.unique) {
|
|
103
|
-
throw new
|
|
102
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` ' +
|
|
104
103
|
'set to false and `unique` set to true');
|
|
105
104
|
}
|
|
106
105
|
if (index.sparse) {
|
|
107
|
-
throw new
|
|
106
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` ' +
|
|
108
107
|
'set to false and `sparse` set to true');
|
|
109
108
|
}
|
|
110
109
|
}
|
|
@@ -171,7 +170,6 @@ SchemaType.prototype.path;
|
|
|
171
170
|
* const schematype = schema.path('name');
|
|
172
171
|
* console.log(schematype.toJSON());
|
|
173
172
|
*
|
|
174
|
-
* @function toJSON
|
|
175
173
|
* @memberOf SchemaType
|
|
176
174
|
* @instance
|
|
177
175
|
* @api public
|
|
@@ -183,6 +181,40 @@ SchemaType.prototype.toJSON = function toJSON() {
|
|
|
183
181
|
return res;
|
|
184
182
|
};
|
|
185
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Helper for creating `{ type: 'object' }` vs `{ bsonType: 'object' }` vs nullable variants.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} type
|
|
188
|
+
* @param {string} bsonType
|
|
189
|
+
* @param {object} [options]
|
|
190
|
+
* @param {boolean} [options.useBsonType=false]
|
|
191
|
+
* @param {boolean} [options._defaultRequired=false]
|
|
192
|
+
* @param {boolean} [options._overrideRequired]
|
|
193
|
+
* @returns {object}
|
|
194
|
+
* @api private
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
SchemaType.prototype._createJSONSchemaTypeDefinition = function _createJSONSchemaTypeDefinition(type, bsonType, options) {
|
|
198
|
+
const useBsonType = options?.useBsonType;
|
|
199
|
+
const isRequired = options?._overrideRequired ??
|
|
200
|
+
(this.options.required == null ?
|
|
201
|
+
(options?._defaultRequired === true || this.path === '_id') :
|
|
202
|
+
this.options.required && typeof this.options.required !== 'function');
|
|
203
|
+
const allowNull = this.options.allowNull !== false;
|
|
204
|
+
|
|
205
|
+
if (useBsonType) {
|
|
206
|
+
if (isRequired || !allowNull) {
|
|
207
|
+
return { bsonType };
|
|
208
|
+
}
|
|
209
|
+
return { bsonType: [bsonType, 'null'] };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (isRequired || !allowNull) {
|
|
213
|
+
return { type };
|
|
214
|
+
}
|
|
215
|
+
return { type: [type, 'null'] };
|
|
216
|
+
};
|
|
217
|
+
|
|
186
218
|
/**
|
|
187
219
|
* The validators that Mongoose should run to validate properties at this SchemaType's path.
|
|
188
220
|
*
|
|
@@ -217,9 +249,9 @@ SchemaType.prototype.validators;
|
|
|
217
249
|
SchemaType.prototype.isRequired;
|
|
218
250
|
|
|
219
251
|
/**
|
|
220
|
-
* Split the current
|
|
252
|
+
* Split the current dotted path into segments
|
|
221
253
|
*
|
|
222
|
-
* @return {
|
|
254
|
+
* @return {string[]|undefined}
|
|
223
255
|
* @api private
|
|
224
256
|
*/
|
|
225
257
|
|
|
@@ -312,14 +344,14 @@ SchemaType.prototype.castFunction = function castFunction(caster, message) {
|
|
|
312
344
|
/**
|
|
313
345
|
* The function that Mongoose calls to cast arbitrary values to this SchemaType.
|
|
314
346
|
*
|
|
315
|
-
* @param {
|
|
347
|
+
* @param {object} value value to cast
|
|
316
348
|
* @param {Document} doc document that triggers the casting
|
|
317
|
-
* @param {
|
|
349
|
+
* @param {boolean} init
|
|
318
350
|
* @api public
|
|
319
351
|
*/
|
|
320
352
|
|
|
321
353
|
SchemaType.prototype.cast = function cast() {
|
|
322
|
-
throw new
|
|
354
|
+
throw new MongooseError('Base SchemaType class does not implement a `cast()` function');
|
|
323
355
|
};
|
|
324
356
|
|
|
325
357
|
/**
|
|
@@ -330,8 +362,8 @@ SchemaType.prototype.cast = function cast() {
|
|
|
330
362
|
* // Make all strings be trimmed by default
|
|
331
363
|
* mongoose.SchemaTypes.String.set('trim', true);
|
|
332
364
|
*
|
|
333
|
-
* @param {
|
|
334
|
-
* @param {
|
|
365
|
+
* @param {string} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
|
|
366
|
+
* @param {any} value The value of the option you'd like to set.
|
|
335
367
|
* @return {void}
|
|
336
368
|
* @static
|
|
337
369
|
* @memberOf SchemaType
|
|
@@ -382,10 +414,10 @@ SchemaType.get = function(getter) {
|
|
|
382
414
|
* #### Example:
|
|
383
415
|
*
|
|
384
416
|
* // values are cast:
|
|
385
|
-
* const schema = new Schema({
|
|
417
|
+
* const schema = new Schema({ num: { type: Number, default: 4.815162342 }})
|
|
386
418
|
* const M = db.model('M', schema)
|
|
387
419
|
* const m = new M;
|
|
388
|
-
* console.log(m.
|
|
420
|
+
* console.log(m.num) // 4.815162342
|
|
389
421
|
*
|
|
390
422
|
* // default unique objects for Mixed types:
|
|
391
423
|
* const schema = new Schema({ mixed: Schema.Types.Mixed });
|
|
@@ -406,7 +438,7 @@ SchemaType.get = function(getter) {
|
|
|
406
438
|
* console.log(m2.mixed); // { added: 1 }
|
|
407
439
|
*
|
|
408
440
|
* @param {Function|any} val The default value to set
|
|
409
|
-
* @return {
|
|
441
|
+
* @return {any|undefined} Returns the set default value.
|
|
410
442
|
* @api public
|
|
411
443
|
*/
|
|
412
444
|
|
|
@@ -417,7 +449,7 @@ SchemaType.prototype.default = function(val) {
|
|
|
417
449
|
return void 0;
|
|
418
450
|
}
|
|
419
451
|
|
|
420
|
-
if (val
|
|
452
|
+
if (val?.instanceOfSchema) {
|
|
421
453
|
throw new MongooseError('Cannot set default value of path `' + this.path +
|
|
422
454
|
'` to a mongoose Schema instance.');
|
|
423
455
|
}
|
|
@@ -445,14 +477,7 @@ SchemaType.prototype.default = function(val) {
|
|
|
445
477
|
* s.path('my.date').index({ expires: 60 });
|
|
446
478
|
* s.path('my.path').index({ unique: true, sparse: true });
|
|
447
479
|
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* _Indexes are created [in the background](https://www.mongodb.com/docs/manual/core/index-creation/#index-creation-background)
|
|
451
|
-
* by default. If `background` is set to `false`, MongoDB will not execute any
|
|
452
|
-
* read/write operations you send until the index build.
|
|
453
|
-
* Specify `background: false` to override Mongoose's default._
|
|
454
|
-
*
|
|
455
|
-
* @param {Object|Boolean|String|Number} options
|
|
480
|
+
* @param {object|boolean|string|number} options
|
|
456
481
|
* @return {SchemaType} this
|
|
457
482
|
* @api public
|
|
458
483
|
*/
|
|
@@ -489,8 +514,8 @@ SchemaType.prototype.index = function(options) {
|
|
|
489
514
|
* Note that the above syntax does **not** work for `bulkWrite()` or `insertMany()`. `bulkWrite()` and `insertMany()`
|
|
490
515
|
* will still throw MongoDB's default `E11000 duplicate key error` message.
|
|
491
516
|
*
|
|
492
|
-
* @param {
|
|
493
|
-
* @param {
|
|
517
|
+
* @param {boolean} value
|
|
518
|
+
* @param {string} [message]
|
|
494
519
|
* @return {SchemaType} this
|
|
495
520
|
* @api public
|
|
496
521
|
*/
|
|
@@ -500,7 +525,7 @@ SchemaType.prototype.unique = function unique(value, message) {
|
|
|
500
525
|
if (!value) {
|
|
501
526
|
return;
|
|
502
527
|
}
|
|
503
|
-
throw new
|
|
528
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
504
529
|
'false and `unique` set to true');
|
|
505
530
|
}
|
|
506
531
|
|
|
@@ -529,7 +554,7 @@ SchemaType.prototype.unique = function unique(value, message) {
|
|
|
529
554
|
* const s = new Schema({ name : { type: String, text : true } })
|
|
530
555
|
* s.path('name').index({ text : true });
|
|
531
556
|
*
|
|
532
|
-
* @param {
|
|
557
|
+
* @param {boolean} bool
|
|
533
558
|
* @return {SchemaType} this
|
|
534
559
|
* @api public
|
|
535
560
|
*/
|
|
@@ -539,7 +564,7 @@ SchemaType.prototype.text = function(bool) {
|
|
|
539
564
|
if (!bool) {
|
|
540
565
|
return this;
|
|
541
566
|
}
|
|
542
|
-
throw new
|
|
567
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
543
568
|
'false and `text` set to true');
|
|
544
569
|
}
|
|
545
570
|
|
|
@@ -566,7 +591,7 @@ SchemaType.prototype.text = function(bool) {
|
|
|
566
591
|
* const s = new Schema({ name: { type: String, sparse: true } });
|
|
567
592
|
* s.path('name').index({ sparse: true });
|
|
568
593
|
*
|
|
569
|
-
* @param {
|
|
594
|
+
* @param {boolean} bool
|
|
570
595
|
* @return {SchemaType} this
|
|
571
596
|
* @api public
|
|
572
597
|
*/
|
|
@@ -576,7 +601,7 @@ SchemaType.prototype.sparse = function(bool) {
|
|
|
576
601
|
if (!bool) {
|
|
577
602
|
return this;
|
|
578
603
|
}
|
|
579
|
-
throw new
|
|
604
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
580
605
|
'false and `sparse` set to true');
|
|
581
606
|
}
|
|
582
607
|
|
|
@@ -631,7 +656,7 @@ SchemaType.prototype.sparse = function(bool) {
|
|
|
631
656
|
* // the property is immutable.
|
|
632
657
|
* Model.updateOne({}, { name: 'test2' }, { strict: false });
|
|
633
658
|
*
|
|
634
|
-
* @param {
|
|
659
|
+
* @param {boolean} bool
|
|
635
660
|
* @return {SchemaType} this
|
|
636
661
|
* @see isNew https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()
|
|
637
662
|
* @api public
|
|
@@ -795,7 +820,7 @@ SchemaType.prototype.set = function(fn) {
|
|
|
795
820
|
* // defining within the schema
|
|
796
821
|
* const s = new Schema({ born: { type: Date, get: dob })
|
|
797
822
|
*
|
|
798
|
-
* // or by
|
|
823
|
+
* // or by retrieving its SchemaType
|
|
799
824
|
* const s = new Schema({ born: Date })
|
|
800
825
|
* s.path('born').get(dob)
|
|
801
826
|
*
|
|
@@ -856,8 +881,8 @@ SchemaType.prototype.get = function(fn) {
|
|
|
856
881
|
* Adds multiple validators for this document path.
|
|
857
882
|
* Calls `validate()` for every element in validators.
|
|
858
883
|
*
|
|
859
|
-
* @param {
|
|
860
|
-
* @returns
|
|
884
|
+
* @param {(RegExp|Function|object)[]} validators
|
|
885
|
+
* @returns {SchemaType}
|
|
861
886
|
*/
|
|
862
887
|
|
|
863
888
|
SchemaType.prototype.validateAll = function(validators) {
|
|
@@ -945,7 +970,7 @@ SchemaType.prototype.validateAll = function(validators) {
|
|
|
945
970
|
* }
|
|
946
971
|
* });
|
|
947
972
|
*
|
|
948
|
-
* You might use asynchronous validators to
|
|
973
|
+
* You might use asynchronous validators to retrieve other documents from the database to validate against or to meet other I/O bound validation needs.
|
|
949
974
|
*
|
|
950
975
|
* Validation occurs `pre('save')` or whenever you manually execute [document#validate](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()).
|
|
951
976
|
*
|
|
@@ -964,12 +989,12 @@ SchemaType.prototype.validateAll = function(validators) {
|
|
|
964
989
|
* // registering an error listener on the Model lets us handle errors more locally
|
|
965
990
|
* Product.on('error', handleError);
|
|
966
991
|
*
|
|
967
|
-
* @param {RegExp|Function|
|
|
992
|
+
* @param {RegExp|Function|object} obj validator function, or hash describing options
|
|
968
993
|
* @param {Function} [obj.validator] validator function. If the validator function returns `undefined` or a truthy value, validation succeeds. If it returns [falsy](https://masteringjs.io/tutorials/fundamentals/falsy) (except `undefined`) or throws an error, validation fails.
|
|
969
|
-
* @param {
|
|
970
|
-
* @param {
|
|
971
|
-
* @param {
|
|
972
|
-
* @param {
|
|
994
|
+
* @param {string|Function} [obj.message] optional error message. If function, should return the error message as a string
|
|
995
|
+
* @param {boolean} [obj.propsParameter=false] If true, Mongoose will pass the validator properties object (with the `validator` function, `message`, etc.) as the 2nd arg to the validator function. This is disabled by default because many validators [rely on positional args](https://github.com/chriso/validator.js#validators), so turning this on may cause unpredictable behavior in external validators.
|
|
996
|
+
* @param {string|Function} [errorMsg] optional error message. If function, should return the error message as a string
|
|
997
|
+
* @param {string} [type] optional validator type
|
|
973
998
|
* @return {SchemaType} this
|
|
974
999
|
* @api public
|
|
975
1000
|
*/
|
|
@@ -1012,7 +1037,7 @@ SchemaType.prototype.validate = function(obj, message, type) {
|
|
|
1012
1037
|
+ arg
|
|
1013
1038
|
+ '. See https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.validate()';
|
|
1014
1039
|
|
|
1015
|
-
throw new
|
|
1040
|
+
throw new MongooseError(msg);
|
|
1016
1041
|
}
|
|
1017
1042
|
this.validate(arg.validator, arg);
|
|
1018
1043
|
}
|
|
@@ -1072,10 +1097,10 @@ SchemaType.prototype.validate = function(obj, message, type) {
|
|
|
1072
1097
|
* the value is not null nor undefined). However, most built-in mongoose schema
|
|
1073
1098
|
* types override the default `checkRequired` function:
|
|
1074
1099
|
*
|
|
1075
|
-
* @param {
|
|
1076
|
-
* @param {
|
|
1100
|
+
* @param {boolean|Function|object} required enable/disable the validator, or function that returns required boolean, or options object
|
|
1101
|
+
* @param {boolean|Function} [options.isRequired] enable/disable the validator, or function that returns required boolean
|
|
1077
1102
|
* @param {Function} [options.ErrorConstructor] custom error constructor. The constructor receives 1 parameter, an object containing the validator properties.
|
|
1078
|
-
* @param {
|
|
1103
|
+
* @param {string} [message] optional custom error message
|
|
1079
1104
|
* @return {SchemaType} this
|
|
1080
1105
|
* @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
|
|
1081
1106
|
* @see SchemaArray#checkRequired https://mongoosejs.com/docs/api/schemaarray.html#SchemaArray.prototype.checkRequired()
|
|
@@ -1118,9 +1143,15 @@ SchemaType.prototype.required = function(required, message) {
|
|
|
1118
1143
|
|
|
1119
1144
|
const _this = this;
|
|
1120
1145
|
this.isRequired = true;
|
|
1146
|
+
this.originalRequiredValue = required;
|
|
1147
|
+
|
|
1148
|
+
if (typeof this.originalRequiredValue !== 'function' &&
|
|
1149
|
+
(utils.hasUserDefinedProperty(this.options, 'allowNull') || this.allowNullValidator != null)) {
|
|
1150
|
+
throw new MongooseError('Path "' + this.path + '" may not have `allowNull` specified when `required` is true');
|
|
1151
|
+
}
|
|
1121
1152
|
|
|
1122
1153
|
this.requiredValidator = function(v) {
|
|
1123
|
-
const cachedRequired = this
|
|
1154
|
+
const cachedRequired = this?.$__?.cachedRequired;
|
|
1124
1155
|
|
|
1125
1156
|
// no validation when this path wasn't selected in the query.
|
|
1126
1157
|
if (cachedRequired != null && !this.$__isSelected(_this.path) && !this[documentIsModified](_this.path)) {
|
|
@@ -1142,8 +1173,6 @@ SchemaType.prototype.required = function(required, message) {
|
|
|
1142
1173
|
|
|
1143
1174
|
return _this.checkRequired(v, this);
|
|
1144
1175
|
};
|
|
1145
|
-
this.originalRequiredValue = required;
|
|
1146
|
-
|
|
1147
1176
|
if (typeof required === 'string') {
|
|
1148
1177
|
message = required;
|
|
1149
1178
|
required = undefined;
|
|
@@ -1159,6 +1188,53 @@ SchemaType.prototype.required = function(required, message) {
|
|
|
1159
1188
|
return this;
|
|
1160
1189
|
};
|
|
1161
1190
|
|
|
1191
|
+
/**
|
|
1192
|
+
* Adds a validator that disallows `null` for this path without making the path
|
|
1193
|
+
* required. `undefined` values still pass validation.
|
|
1194
|
+
*
|
|
1195
|
+
* #### Example:
|
|
1196
|
+
*
|
|
1197
|
+
* const schema = new Schema({
|
|
1198
|
+
* name: { type: String, allowNull: false }
|
|
1199
|
+
* });
|
|
1200
|
+
*
|
|
1201
|
+
* new Model({ name: undefined }).validateSync(); // OK
|
|
1202
|
+
* new Model({ name: null }).validateSync(); // ValidationError
|
|
1203
|
+
*
|
|
1204
|
+
* @param {boolean} allowNull
|
|
1205
|
+
* @return {SchemaType} this
|
|
1206
|
+
* @api public
|
|
1207
|
+
*/
|
|
1208
|
+
|
|
1209
|
+
SchemaType.prototype.allowNull = function(allowNull) {
|
|
1210
|
+
if (arguments.length > 0 && this.isRequired && typeof this.originalRequiredValue !== 'function') {
|
|
1211
|
+
throw new MongooseError('Path "' + this.path + '" may not have `allowNull` specified when `required` is true');
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
this.validators = this.validators.filter(function(v) {
|
|
1215
|
+
return v.validator !== this.allowNullValidator;
|
|
1216
|
+
}, this);
|
|
1217
|
+
|
|
1218
|
+
if (allowNull !== false) {
|
|
1219
|
+
delete this.options.allowNull;
|
|
1220
|
+
delete this.allowNullValidator;
|
|
1221
|
+
return this;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
this.options.allowNull = false;
|
|
1225
|
+
this.allowNullValidator = function(v) {
|
|
1226
|
+
return v !== null;
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
this.validators.push({
|
|
1230
|
+
validator: this.allowNullValidator,
|
|
1231
|
+
message: MongooseError.messages.general.allowNull,
|
|
1232
|
+
type: 'allowNull'
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
return this;
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1162
1238
|
/**
|
|
1163
1239
|
* Set the model that this path refers to. This is the option that [populate](https://mongoosejs.com/docs/populate.html)
|
|
1164
1240
|
* looks at to determine the foreign collection it should query.
|
|
@@ -1179,7 +1255,7 @@ SchemaType.prototype.required = function(required, message) {
|
|
|
1179
1255
|
* user: { type: mongoose.ObjectId, ref: User }
|
|
1180
1256
|
* });
|
|
1181
1257
|
*
|
|
1182
|
-
* @param {
|
|
1258
|
+
* @param {string|Model|Function} ref either a model name, a [Model](https://mongoosejs.com/docs/models.html), or a function that returns a model name or model.
|
|
1183
1259
|
* @return {SchemaType} this
|
|
1184
1260
|
* @api public
|
|
1185
1261
|
*/
|
|
@@ -1192,43 +1268,51 @@ SchemaType.prototype.ref = function(ref) {
|
|
|
1192
1268
|
/**
|
|
1193
1269
|
* Gets the default value
|
|
1194
1270
|
*
|
|
1195
|
-
* @param {
|
|
1196
|
-
* @param {
|
|
1197
|
-
* @
|
|
1271
|
+
* @param {object} parentDoc
|
|
1272
|
+
* @param {boolean} init
|
|
1273
|
+
* @param {object} options
|
|
1274
|
+
* @param {object} [options.context]
|
|
1275
|
+
* @param {boolean} [options.skipCast]
|
|
1276
|
+
* @return {any} The Stored default value.
|
|
1198
1277
|
* @api private
|
|
1199
1278
|
*/
|
|
1200
1279
|
|
|
1201
|
-
SchemaType.prototype.getDefault = function(
|
|
1280
|
+
SchemaType.prototype.getDefault = function getDefault(parentDoc, init, options) {
|
|
1202
1281
|
let ret;
|
|
1203
1282
|
if (this.defaultValue == null) {
|
|
1204
1283
|
return this.defaultValue;
|
|
1205
1284
|
}
|
|
1206
1285
|
if (typeof this.defaultValue === 'function') {
|
|
1286
|
+
// In setDefaultsOnInsert, we pass the Query as `context` option. This is used to
|
|
1287
|
+
// avoid passing the query as the parent doc to `applySetters()` below, because
|
|
1288
|
+
// applySetters assumes parentDoc is a document or null. Queries run setters
|
|
1289
|
+
// separately anyway.
|
|
1290
|
+
const context = options?.context ?? parentDoc;
|
|
1207
1291
|
if (
|
|
1208
1292
|
this.defaultValue === Date.now ||
|
|
1209
1293
|
this.defaultValue === Array ||
|
|
1210
1294
|
this.defaultValue.name.toLowerCase() === 'objectid'
|
|
1211
1295
|
) {
|
|
1212
|
-
ret = this.defaultValue.call(
|
|
1296
|
+
ret = this.defaultValue.call(context);
|
|
1213
1297
|
} else {
|
|
1214
|
-
ret = this.defaultValue.call(
|
|
1298
|
+
ret = this.defaultValue.call(context, context);
|
|
1215
1299
|
}
|
|
1216
1300
|
} else {
|
|
1217
1301
|
ret = this.defaultValue;
|
|
1218
1302
|
}
|
|
1219
1303
|
|
|
1220
|
-
if (ret
|
|
1221
|
-
if (typeof ret === 'object' &&
|
|
1304
|
+
if (ret != null) {
|
|
1305
|
+
if (typeof ret === 'object' && !this.options?.shared) {
|
|
1222
1306
|
ret = clone(ret);
|
|
1223
1307
|
}
|
|
1224
1308
|
|
|
1225
|
-
if (options
|
|
1226
|
-
return this._applySetters(ret,
|
|
1309
|
+
if (options?.skipCast) {
|
|
1310
|
+
return this._applySetters(ret, parentDoc);
|
|
1227
1311
|
}
|
|
1228
1312
|
|
|
1229
|
-
const casted = this.applySetters(ret,
|
|
1313
|
+
const casted = this.applySetters(ret, parentDoc, init, undefined, setOptionsForDefaults);
|
|
1230
1314
|
if (casted && !Array.isArray(casted) && casted.$isSingleNested) {
|
|
1231
|
-
casted.$__parent =
|
|
1315
|
+
casted.$__parent = parentDoc;
|
|
1232
1316
|
}
|
|
1233
1317
|
return casted;
|
|
1234
1318
|
}
|
|
@@ -1238,11 +1322,11 @@ SchemaType.prototype.getDefault = function(scope, init, options) {
|
|
|
1238
1322
|
/**
|
|
1239
1323
|
* Applies setters without casting
|
|
1240
1324
|
*
|
|
1241
|
-
* @param {
|
|
1242
|
-
* @param {
|
|
1243
|
-
* @param {
|
|
1244
|
-
* @param {
|
|
1245
|
-
* @param {
|
|
1325
|
+
* @param {any} value
|
|
1326
|
+
* @param {any} scope
|
|
1327
|
+
* @param {boolean} init
|
|
1328
|
+
* @param {any} priorVal
|
|
1329
|
+
* @param {object} [options]
|
|
1246
1330
|
* @instance
|
|
1247
1331
|
* @api private
|
|
1248
1332
|
*/
|
|
@@ -1272,10 +1356,10 @@ SchemaType.prototype._castNullish = function _castNullish(v) {
|
|
|
1272
1356
|
/**
|
|
1273
1357
|
* Applies setters
|
|
1274
1358
|
*
|
|
1275
|
-
* @param {
|
|
1276
|
-
* @param {
|
|
1277
|
-
* @param {
|
|
1278
|
-
* @return {
|
|
1359
|
+
* @param {any} value
|
|
1360
|
+
* @param {object} scope
|
|
1361
|
+
* @param {boolean} init
|
|
1362
|
+
* @return {any}
|
|
1279
1363
|
* @api private
|
|
1280
1364
|
*/
|
|
1281
1365
|
|
|
@@ -1293,9 +1377,9 @@ SchemaType.prototype.applySetters = function(value, scope, init, priorVal, optio
|
|
|
1293
1377
|
/**
|
|
1294
1378
|
* Applies getters to a value
|
|
1295
1379
|
*
|
|
1296
|
-
* @param {
|
|
1297
|
-
* @param {
|
|
1298
|
-
* @return {
|
|
1380
|
+
* @param {object} value
|
|
1381
|
+
* @param {object} scope
|
|
1382
|
+
* @return {any}
|
|
1299
1383
|
* @api private
|
|
1300
1384
|
*/
|
|
1301
1385
|
|
|
@@ -1327,7 +1411,7 @@ SchemaType.prototype.applyGetters = function(value, scope) {
|
|
|
1327
1411
|
* // .. unless overridden;
|
|
1328
1412
|
* T.find().select('-x').exec(callback);
|
|
1329
1413
|
*
|
|
1330
|
-
* @param {
|
|
1414
|
+
* @param {boolean} val
|
|
1331
1415
|
* @return {SchemaType} this
|
|
1332
1416
|
* @api public
|
|
1333
1417
|
*/
|
|
@@ -1340,63 +1424,53 @@ SchemaType.prototype.select = function select(val) {
|
|
|
1340
1424
|
/**
|
|
1341
1425
|
* Performs a validation of `value` using the validators declared for this SchemaType.
|
|
1342
1426
|
*
|
|
1343
|
-
* @param {
|
|
1344
|
-
* @param {
|
|
1345
|
-
* @param {
|
|
1346
|
-
* @param {
|
|
1347
|
-
* @
|
|
1348
|
-
* @return {Any} If no validators, returns the output from calling `fn`, otherwise no return
|
|
1427
|
+
* @param {any} value
|
|
1428
|
+
* @param {object} scope
|
|
1429
|
+
* @param {object} [options]
|
|
1430
|
+
* @param {string} [options.path]
|
|
1431
|
+
* @return {any} If no validators, returns the output from calling `fn`, otherwise no return
|
|
1349
1432
|
* @api public
|
|
1350
1433
|
*/
|
|
1351
1434
|
|
|
1352
|
-
SchemaType.prototype.doValidate = function(value,
|
|
1435
|
+
SchemaType.prototype.doValidate = async function doValidate(value, scope, options) {
|
|
1353
1436
|
let err = false;
|
|
1354
1437
|
const path = this.path;
|
|
1355
|
-
if (typeof fn !== 'function') {
|
|
1356
|
-
throw new TypeError(`Must pass callback function to doValidate(), got ${typeof fn}`);
|
|
1357
|
-
}
|
|
1358
1438
|
|
|
1359
1439
|
// Avoid non-object `validators`
|
|
1360
1440
|
const validators = this.validators.
|
|
1361
1441
|
filter(v => typeof v === 'object' && v !== null);
|
|
1362
1442
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
if (!count) {
|
|
1366
|
-
return fn(null);
|
|
1443
|
+
if (!validators.length) {
|
|
1444
|
+
return;
|
|
1367
1445
|
}
|
|
1368
1446
|
|
|
1447
|
+
const promises = [];
|
|
1369
1448
|
for (let i = 0, len = validators.length; i < len; ++i) {
|
|
1370
|
-
if (err) {
|
|
1371
|
-
break;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
1449
|
const v = validators[i];
|
|
1375
1450
|
const validator = v.validator;
|
|
1376
1451
|
let ok;
|
|
1377
1452
|
|
|
1378
1453
|
const validatorProperties = isSimpleValidator(v) ? Object.assign({}, v) : clone(v);
|
|
1379
|
-
validatorProperties.path = options
|
|
1454
|
+
validatorProperties.path = options?.path || path;
|
|
1380
1455
|
validatorProperties.fullPath = this.$fullPath;
|
|
1381
1456
|
validatorProperties.value = value;
|
|
1382
1457
|
if (typeof value === 'string') {
|
|
1383
1458
|
validatorProperties.length = value.length;
|
|
1384
|
-
if (validatorProperties.value.length > 30) {
|
|
1385
|
-
validatorProperties.value = validatorProperties.value.slice(0, 30) + '...';
|
|
1386
|
-
}
|
|
1387
1459
|
}
|
|
1388
1460
|
|
|
1389
|
-
if (validator
|
|
1390
|
-
validate(validator.test(value), validatorProperties, scope);
|
|
1461
|
+
if (value === undefined && validator !== this.requiredValidator) {
|
|
1391
1462
|
continue;
|
|
1392
1463
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1464
|
+
if (validator instanceof RegExp) {
|
|
1465
|
+
ok = validator.test(value);
|
|
1466
|
+
if (ok === false) {
|
|
1467
|
+
const ErrorConstructor = validatorProperties.ErrorConstructor || ValidatorError;
|
|
1468
|
+
err = new ErrorConstructor(validatorProperties, scope);
|
|
1469
|
+
err[validatorErrorSymbol] = true;
|
|
1470
|
+
throw err;
|
|
1471
|
+
}
|
|
1395
1472
|
continue;
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
if (value === undefined && validator !== this.requiredValidator) {
|
|
1399
|
-
validate(true, validatorProperties, scope);
|
|
1473
|
+
} else if (typeof validator !== 'function') {
|
|
1400
1474
|
continue;
|
|
1401
1475
|
}
|
|
1402
1476
|
|
|
@@ -1414,39 +1488,36 @@ SchemaType.prototype.doValidate = function(value, fn, scope, options) {
|
|
|
1414
1488
|
}
|
|
1415
1489
|
}
|
|
1416
1490
|
|
|
1417
|
-
if (
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
} else {
|
|
1491
|
+
if (typeof ok?.then === 'function') {
|
|
1492
|
+
promises.push(
|
|
1493
|
+
ok.then(
|
|
1494
|
+
function(ok) {
|
|
1495
|
+
if (ok === false) {
|
|
1496
|
+
const ErrorConstructor = validatorProperties.ErrorConstructor || ValidatorError;
|
|
1497
|
+
err = new ErrorConstructor(validatorProperties, scope);
|
|
1498
|
+
err[validatorErrorSymbol] = true;
|
|
1499
|
+
throw err;
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
function(error) {
|
|
1503
|
+
validatorProperties.reason = error;
|
|
1504
|
+
validatorProperties.message = error.message;
|
|
1505
|
+
ok = false;
|
|
1506
|
+
const ErrorConstructor = validatorProperties.ErrorConstructor || ValidatorError;
|
|
1507
|
+
err = new ErrorConstructor(validatorProperties, scope);
|
|
1508
|
+
err[validatorErrorSymbol] = true;
|
|
1509
|
+
throw err;
|
|
1510
|
+
})
|
|
1511
|
+
);
|
|
1512
|
+
} else if (ok !== undefined && !ok) {
|
|
1442
1513
|
const ErrorConstructor = validatorProperties.ErrorConstructor || ValidatorError;
|
|
1443
1514
|
err = new ErrorConstructor(validatorProperties, scope);
|
|
1444
1515
|
err[validatorErrorSymbol] = true;
|
|
1445
|
-
|
|
1446
|
-
fn(err);
|
|
1447
|
-
});
|
|
1516
|
+
throw err;
|
|
1448
1517
|
}
|
|
1449
1518
|
}
|
|
1519
|
+
|
|
1520
|
+
await Promise.all(promises);
|
|
1450
1521
|
};
|
|
1451
1522
|
|
|
1452
1523
|
|
|
@@ -1466,10 +1537,10 @@ function _validate(ok, validatorProperties) {
|
|
|
1466
1537
|
*
|
|
1467
1538
|
* This method ignores the asynchronous validators.
|
|
1468
1539
|
*
|
|
1469
|
-
* @param {
|
|
1470
|
-
* @param {
|
|
1471
|
-
* @param {
|
|
1472
|
-
* @param {
|
|
1540
|
+
* @param {any} value
|
|
1541
|
+
* @param {object} scope
|
|
1542
|
+
* @param {object} [options]
|
|
1543
|
+
* @param {string} [options.path]
|
|
1473
1544
|
* @return {MongooseError|null}
|
|
1474
1545
|
* @api private
|
|
1475
1546
|
*/
|
|
@@ -1503,14 +1574,11 @@ SchemaType.prototype.doValidateSync = function(value, scope, options) {
|
|
|
1503
1574
|
|
|
1504
1575
|
const validator = v.validator;
|
|
1505
1576
|
const validatorProperties = isSimpleValidator(v) ? Object.assign({}, v) : clone(v);
|
|
1506
|
-
validatorProperties.path = options
|
|
1577
|
+
validatorProperties.path = options?.path || path;
|
|
1507
1578
|
validatorProperties.fullPath = this.$fullPath;
|
|
1508
1579
|
validatorProperties.value = value;
|
|
1509
1580
|
if (typeof value === 'string') {
|
|
1510
1581
|
validatorProperties.length = value.length;
|
|
1511
|
-
if (validatorProperties.value.length > 30) {
|
|
1512
|
-
validatorProperties.value = validatorProperties.value.slice(0, 30) + '...';
|
|
1513
|
-
}
|
|
1514
1582
|
}
|
|
1515
1583
|
let ok = false;
|
|
1516
1584
|
|
|
@@ -1542,7 +1610,7 @@ SchemaType.prototype.doValidateSync = function(value, scope, options) {
|
|
|
1542
1610
|
|
|
1543
1611
|
// Skip any validators that return a promise, we can't handle those
|
|
1544
1612
|
// synchronously
|
|
1545
|
-
if (
|
|
1613
|
+
if (typeof ok?.then === 'function') {
|
|
1546
1614
|
continue;
|
|
1547
1615
|
}
|
|
1548
1616
|
err = _validate(ok, validatorProperties);
|
|
@@ -1558,18 +1626,18 @@ SchemaType.prototype.doValidateSync = function(value, scope, options) {
|
|
|
1558
1626
|
* Determines if value is a valid Reference.
|
|
1559
1627
|
*
|
|
1560
1628
|
* @param {SchemaType} self
|
|
1561
|
-
* @param {
|
|
1629
|
+
* @param {object} value
|
|
1562
1630
|
* @param {Document} doc
|
|
1563
|
-
* @param {
|
|
1564
|
-
* @return {
|
|
1631
|
+
* @param {boolean} init
|
|
1632
|
+
* @return {boolean}
|
|
1565
1633
|
* @api private
|
|
1566
1634
|
*/
|
|
1567
1635
|
|
|
1568
1636
|
SchemaType._isRef = function(self, value, doc, init) {
|
|
1569
1637
|
// fast path
|
|
1570
|
-
let ref = init &&
|
|
1638
|
+
let ref = init && (self.options?.ref || self.options?.refPath);
|
|
1571
1639
|
|
|
1572
|
-
if (!ref && doc
|
|
1640
|
+
if (!ref && doc?.$__ != null) {
|
|
1573
1641
|
// checks for
|
|
1574
1642
|
// - this populated with adhoc model and no ref was set in schema OR
|
|
1575
1643
|
// - setting / pushing values after population
|
|
@@ -1703,10 +1771,10 @@ SchemaType.prototype.$conditionalHandlers = {
|
|
|
1703
1771
|
/**
|
|
1704
1772
|
* Cast the given value with the given optional query operator.
|
|
1705
1773
|
*
|
|
1706
|
-
* @param {
|
|
1707
|
-
* @param {
|
|
1774
|
+
* @param {string} [$conditional] query operator, like `$eq` or `$in`
|
|
1775
|
+
* @param {any} val
|
|
1708
1776
|
* @param {Query} context
|
|
1709
|
-
* @return {
|
|
1777
|
+
* @return {any}
|
|
1710
1778
|
* @api private
|
|
1711
1779
|
*/
|
|
1712
1780
|
|
|
@@ -1715,7 +1783,7 @@ SchemaType.prototype.castForQuery = function($conditional, val, context) {
|
|
|
1715
1783
|
if ($conditional != null) {
|
|
1716
1784
|
handler = this.$conditionalHandlers[$conditional];
|
|
1717
1785
|
if (!handler) {
|
|
1718
|
-
throw new
|
|
1786
|
+
throw new MongooseError('Can\'t use ' + $conditional);
|
|
1719
1787
|
}
|
|
1720
1788
|
return handler.call(this, val, context);
|
|
1721
1789
|
}
|
|
@@ -1759,8 +1827,8 @@ SchemaType.checkRequired = function(fn) {
|
|
|
1759
1827
|
/**
|
|
1760
1828
|
* Default check for if this path satisfies the `required` validator.
|
|
1761
1829
|
*
|
|
1762
|
-
* @param {
|
|
1763
|
-
* @return {
|
|
1830
|
+
* @param {any} val
|
|
1831
|
+
* @return {boolean} `true` when the value is not `null`, `false` otherwise
|
|
1764
1832
|
* @api private
|
|
1765
1833
|
*/
|
|
1766
1834
|
|
|
@@ -1780,6 +1848,7 @@ SchemaType.prototype.clone = function() {
|
|
|
1780
1848
|
const schematype = new this.constructor(this.path, options, this.instance, this.parentSchema);
|
|
1781
1849
|
schematype.validators = this.validators.slice();
|
|
1782
1850
|
if (this.requiredValidator !== undefined) schematype.requiredValidator = this.requiredValidator;
|
|
1851
|
+
if (this.allowNullValidator !== undefined) schematype.allowNullValidator = this.allowNullValidator;
|
|
1783
1852
|
if (this.defaultValue !== undefined) schematype.defaultValue = this.defaultValue;
|
|
1784
1853
|
if (this.$immutable !== undefined && this.options.immutable === undefined) {
|
|
1785
1854
|
schematype.$immutable = this.$immutable;
|
|
@@ -1811,7 +1880,7 @@ SchemaType.prototype.clone = function() {
|
|
|
1811
1880
|
*/
|
|
1812
1881
|
|
|
1813
1882
|
SchemaType.prototype.getEmbeddedSchemaType = function getEmbeddedSchemaType() {
|
|
1814
|
-
return this
|
|
1883
|
+
return this.embeddedSchemaType;
|
|
1815
1884
|
};
|
|
1816
1885
|
|
|
1817
1886
|
/*!
|
|
@@ -1825,13 +1894,13 @@ SchemaType.prototype._duplicateKeyErrorMessage = null;
|
|
|
1825
1894
|
/**
|
|
1826
1895
|
* Returns this schema type's representation in a JSON schema.
|
|
1827
1896
|
*
|
|
1828
|
-
* @param [options]
|
|
1829
|
-
* @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
1830
|
-
* @returns {
|
|
1897
|
+
* @param {object} [options]
|
|
1898
|
+
* @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
1899
|
+
* @returns {object} JSON schema properties
|
|
1831
1900
|
*/
|
|
1832
1901
|
|
|
1833
1902
|
SchemaType.prototype.toJSONSchema = function toJSONSchema(_options) { // eslint-disable-line no-unused-vars
|
|
1834
|
-
throw new
|
|
1903
|
+
throw new MongooseError(`Converting unsupported SchemaType to JSON Schema: ${this.instance} at path "${this.path}"`);
|
|
1835
1904
|
};
|
|
1836
1905
|
|
|
1837
1906
|
/**
|