@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 SchemaDocumentArrayOptions =
|
|
|
12
12
|
require('../options/schemaDocumentArrayOptions');
|
|
13
13
|
const SchemaType = require('../schemaType');
|
|
14
14
|
const cast = require('../cast');
|
|
15
|
-
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
|
|
16
15
|
const discriminator = require('../helpers/model/discriminator');
|
|
17
16
|
const handleIdOption = require('../helpers/schema/handleIdOption');
|
|
18
17
|
const handleSpreadDoc = require('../helpers/document/handleSpreadDoc');
|
|
@@ -31,44 +30,51 @@ let Subdocument;
|
|
|
31
30
|
/**
|
|
32
31
|
* SubdocsArray SchemaType constructor
|
|
33
32
|
*
|
|
34
|
-
* @param {
|
|
33
|
+
* @param {string} key
|
|
35
34
|
* @param {Schema} schema
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
35
|
+
* @param {object} options
|
|
36
|
+
* @param {object} schemaOptions
|
|
38
37
|
* @param {Schema} parentSchema
|
|
39
38
|
* @inherits SchemaArray
|
|
40
39
|
* @api public
|
|
41
40
|
*/
|
|
42
41
|
|
|
43
42
|
function SchemaDocumentArray(key, schema, options, schemaOptions, parentSchema) {
|
|
44
|
-
if (schema.options
|
|
43
|
+
if (schema.options?.timeseries) {
|
|
45
44
|
throw new InvalidSchemaOptionError(key, 'timeseries');
|
|
46
45
|
}
|
|
47
|
-
const schemaTypeIdOption = SchemaDocumentArray.defaultOptions
|
|
48
|
-
SchemaDocumentArray.defaultOptions._id;
|
|
46
|
+
const schemaTypeIdOption = SchemaDocumentArray.defaultOptions?._id;
|
|
49
47
|
if (schemaTypeIdOption != null) {
|
|
50
48
|
schemaOptions = schemaOptions || {};
|
|
51
49
|
schemaOptions._id = schemaTypeIdOption;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
if (schemaOptions
|
|
52
|
+
if (schemaOptions?._id != null) {
|
|
55
53
|
schema = handleIdOption(schema, schemaOptions);
|
|
56
|
-
} else if (options
|
|
54
|
+
} else if (options?._id != null) {
|
|
57
55
|
schema = handleIdOption(schema, options);
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
const
|
|
61
|
-
|
|
58
|
+
const Constructor = _createConstructor(schema, options);
|
|
59
|
+
Constructor.prototype.$basePath = key;
|
|
60
|
+
Constructor.path = key;
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
const $parentSchemaType = this;
|
|
63
|
+
const embeddedSchemaType = new DocumentArrayElement(key + '.$', schema, {
|
|
64
|
+
...(schemaOptions || {}),
|
|
65
|
+
$parentSchemaType,
|
|
66
|
+
Constructor
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
SchemaArray.call(this, key, embeddedSchemaType, options, null, parentSchema);
|
|
64
70
|
|
|
65
71
|
this.schema = schema;
|
|
66
72
|
// EmbeddedDocument schematype options
|
|
67
73
|
this.schemaOptions = schemaOptions || {};
|
|
68
74
|
this.$isMongooseDocumentArray = true;
|
|
69
|
-
this.Constructor =
|
|
75
|
+
this.Constructor = Constructor;
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
Constructor.base = schema.base;
|
|
72
78
|
|
|
73
79
|
const fn = this.defaultValue;
|
|
74
80
|
|
|
@@ -82,20 +88,6 @@ function SchemaDocumentArray(key, schema, options, schemaOptions, parentSchema)
|
|
|
82
88
|
return arr;
|
|
83
89
|
});
|
|
84
90
|
}
|
|
85
|
-
|
|
86
|
-
const $parentSchemaType = this;
|
|
87
|
-
this.$embeddedSchemaType = new DocumentArrayElement(
|
|
88
|
-
key + '.$',
|
|
89
|
-
{
|
|
90
|
-
...(schemaOptions || {}),
|
|
91
|
-
$parentSchemaType
|
|
92
|
-
},
|
|
93
|
-
schemaOptions,
|
|
94
|
-
parentSchema
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
this.$embeddedSchemaType.caster = this.Constructor;
|
|
98
|
-
this.$embeddedSchemaType.schema = this.schema;
|
|
99
91
|
}
|
|
100
92
|
|
|
101
93
|
/**
|
|
@@ -156,7 +148,7 @@ function _createConstructor(schema, options, baseClass) {
|
|
|
156
148
|
|
|
157
149
|
schema._preCompile();
|
|
158
150
|
|
|
159
|
-
const proto = baseClass
|
|
151
|
+
const proto = baseClass?.prototype ?? Subdocument.prototype;
|
|
160
152
|
EmbeddedDocument.prototype = Object.create(proto);
|
|
161
153
|
EmbeddedDocument.prototype.$__setSchema(schema);
|
|
162
154
|
EmbeddedDocument.schema = schema;
|
|
@@ -195,11 +187,11 @@ function _createConstructor(schema, options, baseClass) {
|
|
|
195
187
|
* const docArrayPath = parentSchema.path('shapes');
|
|
196
188
|
* docArrayPath.discriminator('Circle', Schema({ radius: Number }));
|
|
197
189
|
*
|
|
198
|
-
* @param {
|
|
190
|
+
* @param {string} name
|
|
199
191
|
* @param {Schema} schema fields to add to the schema for instances of this sub-class
|
|
200
|
-
* @param {
|
|
201
|
-
* @param {
|
|
202
|
-
* @param {
|
|
192
|
+
* @param {object|string} [options] If string, same as `options.value`.
|
|
193
|
+
* @param {string} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter.
|
|
194
|
+
* @param {boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning.
|
|
203
195
|
* @see discriminators https://mongoosejs.com/docs/discriminators.html
|
|
204
196
|
* @return {Function} the constructor Mongoose will use for creating instances of this discriminator model
|
|
205
197
|
* @api public
|
|
@@ -218,93 +210,62 @@ SchemaDocumentArray.prototype.discriminator = function(name, schema, options) {
|
|
|
218
210
|
schema = schema.clone();
|
|
219
211
|
}
|
|
220
212
|
|
|
221
|
-
schema = discriminator(this.
|
|
213
|
+
schema = discriminator(this.Constructor, name, schema, tiedValue, null, null, options?.overwriteExisting);
|
|
222
214
|
|
|
223
|
-
const EmbeddedDocument = _createConstructor(schema, null, this.
|
|
224
|
-
EmbeddedDocument.baseCasterConstructor = this.
|
|
215
|
+
const EmbeddedDocument = _createConstructor(schema, null, this.Constructor);
|
|
216
|
+
EmbeddedDocument.baseCasterConstructor = this.Constructor;
|
|
225
217
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
} catch (error) {
|
|
231
|
-
// Ignore error, only happens on old versions of node
|
|
232
|
-
}
|
|
218
|
+
Object.defineProperty(EmbeddedDocument, 'name', {
|
|
219
|
+
value: name
|
|
220
|
+
});
|
|
233
221
|
|
|
234
|
-
this.
|
|
222
|
+
this.Constructor.discriminators[name] = EmbeddedDocument;
|
|
235
223
|
|
|
236
|
-
return this.
|
|
224
|
+
return this.Constructor.discriminators[name];
|
|
237
225
|
};
|
|
238
226
|
|
|
239
227
|
/**
|
|
240
228
|
* Performs local validations first, then validations on each embedded doc
|
|
241
229
|
*
|
|
242
|
-
* @api
|
|
230
|
+
* @api public
|
|
243
231
|
*/
|
|
244
232
|
|
|
245
|
-
SchemaDocumentArray.prototype.doValidate = function(array,
|
|
233
|
+
SchemaDocumentArray.prototype.doValidate = async function doValidate(array, scope, options) {
|
|
246
234
|
// lazy load
|
|
247
235
|
MongooseDocumentArray || (MongooseDocumentArray = require('../types/documentArray'));
|
|
248
236
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
237
|
+
await SchemaType.prototype.doValidate.call(this, array, scope);
|
|
238
|
+
if (options?.updateValidator) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!utils.isMongooseDocumentArray(array)) {
|
|
242
|
+
array = new MongooseDocumentArray(array, this.path, scope);
|
|
254
243
|
}
|
|
255
244
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return fn(err);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
let count = array && array.length;
|
|
262
|
-
let error;
|
|
263
|
-
|
|
264
|
-
if (!count) {
|
|
265
|
-
return fn();
|
|
266
|
-
}
|
|
267
|
-
if (options && options.updateValidator) {
|
|
268
|
-
return fn();
|
|
269
|
-
}
|
|
270
|
-
if (!utils.isMongooseDocumentArray(array)) {
|
|
271
|
-
array = new MongooseDocumentArray(array, _this.path, scope);
|
|
272
|
-
}
|
|
273
|
-
|
|
245
|
+
const promises = [];
|
|
246
|
+
for (let i = 0; i < array.length; ++i) {
|
|
274
247
|
// handle sparse arrays, do not use array.forEach which does not
|
|
275
248
|
// iterate over sparse elements yet reports array.length including
|
|
276
249
|
// them :(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
250
|
+
let doc = array[i];
|
|
251
|
+
if (doc == null) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
// If you set the array index directly, the doc might not yet be
|
|
255
|
+
// a full fledged mongoose subdoc, so make it into one.
|
|
256
|
+
if (!(doc instanceof Subdocument)) {
|
|
257
|
+
const Constructor = getConstructor(this.Constructor, array[i]);
|
|
258
|
+
doc = array[i] = new Constructor(doc, array, undefined, undefined, i);
|
|
283
259
|
}
|
|
284
260
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
let doc = array[i];
|
|
288
|
-
if (doc == null) {
|
|
289
|
-
--count || fn(error);
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// If you set the array index directly, the doc might not yet be
|
|
294
|
-
// a full fledged mongoose subdoc, so make it into one.
|
|
295
|
-
if (!(doc instanceof Subdocument)) {
|
|
296
|
-
const Constructor = getConstructor(_this.casterConstructor, array[i]);
|
|
297
|
-
doc = array[i] = new Constructor(doc, array, undefined, undefined, i);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (options != null && options.validateModifiedOnly && !doc.$isModified()) {
|
|
301
|
-
--count || fn(error);
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
doc.$__validate(null, options, callback);
|
|
261
|
+
if (options?.validateModifiedOnly && !doc.$isModified()) {
|
|
262
|
+
continue;
|
|
306
263
|
}
|
|
264
|
+
|
|
265
|
+
promises.push(doc.validate(null, options));
|
|
307
266
|
}
|
|
267
|
+
|
|
268
|
+
await Promise.all(promises);
|
|
308
269
|
};
|
|
309
270
|
|
|
310
271
|
/**
|
|
@@ -324,7 +285,7 @@ SchemaDocumentArray.prototype.doValidateSync = function(array, scope, options) {
|
|
|
324
285
|
return schemaTypeError;
|
|
325
286
|
}
|
|
326
287
|
|
|
327
|
-
const count = array
|
|
288
|
+
const count = array?.length;
|
|
328
289
|
let resultError = null;
|
|
329
290
|
|
|
330
291
|
if (!count) {
|
|
@@ -345,11 +306,11 @@ SchemaDocumentArray.prototype.doValidateSync = function(array, scope, options) {
|
|
|
345
306
|
// If you set the array index directly, the doc might not yet be
|
|
346
307
|
// a full fledged mongoose subdoc, so make it into one.
|
|
347
308
|
if (!(doc instanceof Subdocument)) {
|
|
348
|
-
const Constructor = getConstructor(this.
|
|
309
|
+
const Constructor = getConstructor(this.Constructor, array[i]);
|
|
349
310
|
doc = array[i] = new Constructor(doc, array, undefined, undefined, i);
|
|
350
311
|
}
|
|
351
312
|
|
|
352
|
-
if (options
|
|
313
|
+
if (options?.validateModifiedOnly && !doc.$isModified()) {
|
|
353
314
|
continue;
|
|
354
315
|
}
|
|
355
316
|
|
|
@@ -376,7 +337,7 @@ SchemaDocumentArray.prototype.getDefault = function(scope, init, options) {
|
|
|
376
337
|
return ret;
|
|
377
338
|
}
|
|
378
339
|
|
|
379
|
-
if (options
|
|
340
|
+
if (options?.skipCast) {
|
|
380
341
|
return ret;
|
|
381
342
|
}
|
|
382
343
|
|
|
@@ -390,7 +351,7 @@ SchemaDocumentArray.prototype.getDefault = function(scope, init, options) {
|
|
|
390
351
|
ret = new MongooseDocumentArray(ret, this.path, scope);
|
|
391
352
|
|
|
392
353
|
for (let i = 0; i < ret.length; ++i) {
|
|
393
|
-
const Constructor = getConstructor(this.
|
|
354
|
+
const Constructor = getConstructor(this.Constructor, ret[i]);
|
|
394
355
|
const _subdoc = new Constructor({}, ret, undefined,
|
|
395
356
|
undefined, i);
|
|
396
357
|
_subdoc.$init(ret[i]);
|
|
@@ -413,7 +374,7 @@ const initDocumentOptions = Object.freeze({ skipId: false, willInit: true });
|
|
|
413
374
|
/**
|
|
414
375
|
* Casts contents
|
|
415
376
|
*
|
|
416
|
-
* @param {
|
|
377
|
+
* @param {object} value
|
|
417
378
|
* @param {Document} document that triggers the casting
|
|
418
379
|
* @api private
|
|
419
380
|
*/
|
|
@@ -423,7 +384,7 @@ SchemaDocumentArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
423
384
|
MongooseDocumentArray || (MongooseDocumentArray = require('../types/documentArray'));
|
|
424
385
|
|
|
425
386
|
// Skip casting if `value` is the same as the previous value, no need to cast. See gh-9266
|
|
426
|
-
if (value
|
|
387
|
+
if (value?.[arrayPathSymbol] != null && value === prev) {
|
|
427
388
|
return value;
|
|
428
389
|
}
|
|
429
390
|
|
|
@@ -468,7 +429,7 @@ SchemaDocumentArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
468
429
|
continue;
|
|
469
430
|
}
|
|
470
431
|
|
|
471
|
-
const Constructor = getConstructor(this.
|
|
432
|
+
const Constructor = getConstructor(this.Constructor, rawArray[i]);
|
|
472
433
|
|
|
473
434
|
const spreadDoc = handleSpreadDoc(rawArray[i], true);
|
|
474
435
|
if (rawArray[i] !== spreadDoc) {
|
|
@@ -476,7 +437,11 @@ SchemaDocumentArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
476
437
|
}
|
|
477
438
|
|
|
478
439
|
if (rawArray[i] instanceof Subdocument) {
|
|
479
|
-
if
|
|
440
|
+
// gh-15973: Clone if subdocument has a different parent, or if it already has a
|
|
441
|
+
// different __index (e.g. reordered or duplicated in the array). If __index is null,
|
|
442
|
+
// we can safely set it without cloning.
|
|
443
|
+
if (rawArray[i][documentArrayParent] !== doc ||
|
|
444
|
+
(rawArray[i].__index != null && rawArray[i].__index !== i)) {
|
|
480
445
|
if (init) {
|
|
481
446
|
const subdoc = new Constructor(null, value, initDocumentOptions, selected, i);
|
|
482
447
|
rawArray[i] = subdoc.$init(rawArray[i]);
|
|
@@ -498,9 +463,15 @@ SchemaDocumentArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
498
463
|
}
|
|
499
464
|
|
|
500
465
|
subdoc = new Constructor(null, value, initDocumentOptions, selected, i);
|
|
466
|
+
// Don't pass `path` to $init - it's only for this DocumentArray itself, not its element fields.
|
|
467
|
+
// Element subdocuments use relative paths internally for change tracking.
|
|
468
|
+
if (options.path != null) {
|
|
469
|
+
options = { ...options };
|
|
470
|
+
delete options.path;
|
|
471
|
+
}
|
|
501
472
|
rawArray[i] = subdoc.$init(rawArray[i], options);
|
|
502
473
|
} else {
|
|
503
|
-
if (
|
|
474
|
+
if (typeof prev?.id === 'function') {
|
|
504
475
|
subdoc = prev.id(rawArray[i]._id);
|
|
505
476
|
}
|
|
506
477
|
|
|
@@ -565,8 +536,8 @@ SchemaDocumentArray.prototype.applyGetters = function(value, scope) {
|
|
|
565
536
|
* Necessary for proper default application of subdocument values.
|
|
566
537
|
*
|
|
567
538
|
* @param {DocumentArrayPath} array the array to scope `fields` paths
|
|
568
|
-
* @param {
|
|
569
|
-
* @param {
|
|
539
|
+
* @param {object|undefined} fields the root fields selected in the query
|
|
540
|
+
* @param {boolean|undefined} init if we are being created part of a query result
|
|
570
541
|
* @api private
|
|
571
542
|
*/
|
|
572
543
|
|
|
@@ -612,11 +583,11 @@ SchemaDocumentArray.defaultOptions = {};
|
|
|
612
583
|
*
|
|
613
584
|
* #### Example:
|
|
614
585
|
*
|
|
615
|
-
* // Make all
|
|
616
|
-
* mongoose.Schema.DocumentArray.set('_id', false);
|
|
586
|
+
* // Make all document arrays not have `_id` by default.
|
|
587
|
+
* mongoose.Schema.Types.DocumentArray.set('_id', false);
|
|
617
588
|
*
|
|
618
|
-
* @param {
|
|
619
|
-
* @param {
|
|
589
|
+
* @param {string} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
|
|
590
|
+
* @param {any} value The value of the option you'd like to set.
|
|
620
591
|
* @return {void}
|
|
621
592
|
* @function set
|
|
622
593
|
* @static
|
|
@@ -658,38 +629,30 @@ function cast$elemMatch(val, context) {
|
|
|
658
629
|
|
|
659
630
|
// Is this an embedded discriminator and is the discriminator key set?
|
|
660
631
|
// If so, use the discriminator schema. See gh-7449
|
|
661
|
-
const discriminatorKey = this
|
|
662
|
-
|
|
663
|
-
this.casterConstructor.schema &&
|
|
664
|
-
this.casterConstructor.schema.options &&
|
|
665
|
-
this.casterConstructor.schema.options.discriminatorKey;
|
|
666
|
-
const discriminators = this &&
|
|
667
|
-
this.casterConstructor &&
|
|
668
|
-
this.casterConstructor.schema &&
|
|
669
|
-
this.casterConstructor.schema.discriminators || {};
|
|
632
|
+
const discriminatorKey = this?.Constructor?.schema?.options?.discriminatorKey;
|
|
633
|
+
const discriminators = this?.Constructor?.schema?.discriminators || {};
|
|
670
634
|
if (discriminatorKey != null &&
|
|
671
635
|
val[discriminatorKey] != null &&
|
|
672
636
|
discriminators[val[discriminatorKey]] != null) {
|
|
673
|
-
return cast(discriminators[val[discriminatorKey]], val, null, this
|
|
637
|
+
return cast(discriminators[val[discriminatorKey]], val, null, this?.$$context);
|
|
674
638
|
}
|
|
675
639
|
|
|
676
|
-
const schema = this.
|
|
677
|
-
return cast(schema, val, null, this
|
|
640
|
+
const schema = this.Constructor.schema ?? context.schema;
|
|
641
|
+
return cast(schema, val, null, this?.$$context);
|
|
678
642
|
}
|
|
679
643
|
|
|
680
644
|
/**
|
|
681
645
|
* Returns this schema type's representation in a JSON schema.
|
|
682
646
|
*
|
|
683
|
-
* @param [options]
|
|
684
|
-
* @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
685
|
-
* @returns {
|
|
647
|
+
* @param {object} [options]
|
|
648
|
+
* @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
649
|
+
* @returns {object} JSON schema properties
|
|
686
650
|
*/
|
|
687
651
|
|
|
688
652
|
SchemaDocumentArray.prototype.toJSONSchema = function toJSONSchema(options) {
|
|
689
|
-
const itemsTypeDefinition =
|
|
690
|
-
const isRequired = this.options.required && typeof this.options.required !== 'function';
|
|
653
|
+
const itemsTypeDefinition = this._createJSONSchemaTypeDefinition('object', 'object', { ...options, _overrideRequired: false });
|
|
691
654
|
return {
|
|
692
|
-
...
|
|
655
|
+
...this._createJSONSchemaTypeDefinition('array', 'array', options),
|
|
693
656
|
items: { ...itemsTypeDefinition, ...this.schema.toJSONSchema(options) }
|
|
694
657
|
};
|
|
695
658
|
};
|
|
@@ -10,18 +10,22 @@ const SchemaSubdocument = require('./subdocument');
|
|
|
10
10
|
const getConstructor = require('../helpers/discriminator/getConstructor');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* DocumentArrayElement SchemaType constructor.
|
|
13
|
+
* DocumentArrayElement SchemaType constructor. Mongoose calls this internally when you define a new document array in your schema.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* #### Example:
|
|
16
|
+
* const schema = new Schema({ users: [{ name: String }] });
|
|
17
|
+
* schema.path('users.$'); // SchemaDocumentArrayElement with schema `new Schema({ name: String })`
|
|
18
|
+
*
|
|
19
|
+
* @param {string} path
|
|
20
|
+
* @param {Schema} schema
|
|
21
|
+
* @param {object} options
|
|
18
22
|
* @param {Schema} parentSchema
|
|
19
23
|
* @inherits SchemaType
|
|
20
24
|
* @api public
|
|
21
25
|
*/
|
|
22
26
|
|
|
23
|
-
function SchemaDocumentArrayElement(path,
|
|
24
|
-
this.$parentSchemaType = options
|
|
27
|
+
function SchemaDocumentArrayElement(path, schema, options, parentSchema) {
|
|
28
|
+
this.$parentSchemaType = options?.$parentSchemaType;
|
|
25
29
|
if (!this.$parentSchemaType) {
|
|
26
30
|
throw new MongooseError('Cannot create DocumentArrayElement schematype without a parent');
|
|
27
31
|
}
|
|
@@ -30,6 +34,8 @@ function SchemaDocumentArrayElement(path, options, _schemaOptions, parentSchema)
|
|
|
30
34
|
SchemaType.call(this, path, options, 'DocumentArrayElement', parentSchema);
|
|
31
35
|
|
|
32
36
|
this.$isMongooseDocumentArrayElement = true;
|
|
37
|
+
this.Constructor = options?.Constructor;
|
|
38
|
+
this.schema = schema;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
/**
|
|
@@ -42,6 +48,36 @@ SchemaDocumentArrayElement.schemaName = 'DocumentArrayElement';
|
|
|
42
48
|
|
|
43
49
|
SchemaDocumentArrayElement.defaultOptions = {};
|
|
44
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Sets a default option for all SchemaDocumentArrayElement instances.
|
|
53
|
+
*
|
|
54
|
+
* #### Example:
|
|
55
|
+
*
|
|
56
|
+
* // Make all document array elements have option `_id` equal to false.
|
|
57
|
+
* mongoose.Schema.Types.DocumentArrayElement.set('_id', false);
|
|
58
|
+
*
|
|
59
|
+
* @param {string} option The name of the option you'd like to set
|
|
60
|
+
* @param {any} value The value of the option you'd like to set.
|
|
61
|
+
* @return {void}
|
|
62
|
+
* @function set
|
|
63
|
+
* @static
|
|
64
|
+
* @api public
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
SchemaDocumentArrayElement.set = SchemaType.set;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Attaches a getter for all DocumentArrayElement instances
|
|
71
|
+
*
|
|
72
|
+
* @param {Function} getter
|
|
73
|
+
* @return {this}
|
|
74
|
+
* @function get
|
|
75
|
+
* @static
|
|
76
|
+
* @api public
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
SchemaDocumentArrayElement.get = SchemaType.get;
|
|
80
|
+
|
|
45
81
|
/*!
|
|
46
82
|
* Inherits from SchemaType.
|
|
47
83
|
*/
|
|
@@ -51,7 +87,7 @@ SchemaDocumentArrayElement.prototype.constructor = SchemaDocumentArrayElement;
|
|
|
51
87
|
/**
|
|
52
88
|
* Casts `val` for DocumentArrayElement.
|
|
53
89
|
*
|
|
54
|
-
* @param {
|
|
90
|
+
* @param {object} value to cast
|
|
55
91
|
* @api private
|
|
56
92
|
*/
|
|
57
93
|
|
|
@@ -60,21 +96,19 @@ SchemaDocumentArrayElement.prototype.cast = function(...args) {
|
|
|
60
96
|
};
|
|
61
97
|
|
|
62
98
|
/**
|
|
63
|
-
*
|
|
99
|
+
* Async validation on this individual array element
|
|
64
100
|
*
|
|
65
|
-
* @
|
|
66
|
-
* @param {any} [val]
|
|
67
|
-
* @api private
|
|
101
|
+
* @api public
|
|
68
102
|
*/
|
|
69
103
|
|
|
70
|
-
SchemaDocumentArrayElement.prototype.doValidate = function(value,
|
|
71
|
-
const Constructor = getConstructor(this.
|
|
104
|
+
SchemaDocumentArrayElement.prototype.doValidate = async function doValidate(value, scope, options) {
|
|
105
|
+
const Constructor = getConstructor(this.Constructor, value);
|
|
72
106
|
|
|
73
107
|
if (value && !(value instanceof Constructor)) {
|
|
74
|
-
value = new Constructor(value, scope, null, null, options
|
|
108
|
+
value = new Constructor(value, scope, null, null, options?.index ?? null);
|
|
75
109
|
}
|
|
76
110
|
|
|
77
|
-
return SchemaSubdocument.prototype.doValidate.call(this, value,
|
|
111
|
+
return SchemaSubdocument.prototype.doValidate.call(this, value, scope, options);
|
|
78
112
|
};
|
|
79
113
|
|
|
80
114
|
/**
|
|
@@ -89,7 +123,7 @@ SchemaDocumentArrayElement.prototype.clone = function() {
|
|
|
89
123
|
const ret = SchemaType.prototype.clone.apply(this, arguments);
|
|
90
124
|
delete this.options.$parentSchemaType;
|
|
91
125
|
|
|
92
|
-
ret.
|
|
126
|
+
ret.Constructor = this.Constructor;
|
|
93
127
|
ret.schema = this.schema;
|
|
94
128
|
|
|
95
129
|
return ret;
|
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
const CastError = require('../error/cast');
|
|
8
8
|
const SchemaType = require('../schemaType');
|
|
9
9
|
const castDouble = require('../cast/double');
|
|
10
|
-
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Double SchemaType constructor.
|
|
14
13
|
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
14
|
+
* @param {string} path
|
|
15
|
+
* @param {object} options
|
|
16
|
+
* @param {object} schemaOptions
|
|
18
17
|
* @param {Schema} parentSchema
|
|
19
18
|
* @inherits SchemaType
|
|
20
19
|
* @api public
|
|
@@ -52,10 +51,10 @@ SchemaDouble._cast = castDouble;
|
|
|
52
51
|
* #### Example:
|
|
53
52
|
*
|
|
54
53
|
* // Make all Double fields required by default
|
|
55
|
-
* mongoose.Schema.Double.set('required', true);
|
|
54
|
+
* mongoose.Schema.Types.Double.set('required', true);
|
|
56
55
|
*
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
56
|
+
* @param {string} option The option you'd like to set the value for
|
|
57
|
+
* @param {any} value value for option
|
|
59
58
|
* @return {undefined}
|
|
60
59
|
* @function set
|
|
61
60
|
* @static
|
|
@@ -72,7 +71,7 @@ SchemaDouble.setters = [];
|
|
|
72
71
|
* #### Example:
|
|
73
72
|
*
|
|
74
73
|
* // Converts Double to be a represent milliseconds upon access
|
|
75
|
-
* mongoose.Schema.Double.get(v => v == null ? '0.000 ms' : v.toString() + ' ms');
|
|
74
|
+
* mongoose.Schema.Types.Double.get(v => v == null ? '0.000 ms' : v.toString() + ' ms');
|
|
76
75
|
*
|
|
77
76
|
* @param {Function} getter
|
|
78
77
|
* @return {this}
|
|
@@ -112,7 +111,7 @@ SchemaDouble._defaultCaster = v => {
|
|
|
112
111
|
* });
|
|
113
112
|
*
|
|
114
113
|
* // Or disable casting for Doubles entirely (only JS numbers are permitted)
|
|
115
|
-
* mongoose.Schema.Double.cast(false);
|
|
114
|
+
* mongoose.Schema.Types.Double.cast(false);
|
|
116
115
|
*
|
|
117
116
|
*
|
|
118
117
|
* @param {Function} caster
|
|
@@ -157,8 +156,8 @@ SchemaDouble.checkRequired = SchemaType.checkRequired;
|
|
|
157
156
|
/**
|
|
158
157
|
* Check if the given value satisfies a required validator.
|
|
159
158
|
*
|
|
160
|
-
* @param {
|
|
161
|
-
* @return {
|
|
159
|
+
* @param {any} value
|
|
160
|
+
* @return {boolean}
|
|
162
161
|
* @api public
|
|
163
162
|
*/
|
|
164
163
|
|
|
@@ -169,8 +168,8 @@ SchemaDouble.prototype.checkRequired = function(value) {
|
|
|
169
168
|
/**
|
|
170
169
|
* Casts to Double
|
|
171
170
|
*
|
|
172
|
-
* @param {
|
|
173
|
-
* @param {
|
|
171
|
+
* @param {object} value
|
|
172
|
+
* @param {object} model this value is optional
|
|
174
173
|
* @api private
|
|
175
174
|
*/
|
|
176
175
|
|
|
@@ -225,14 +224,13 @@ Object.defineProperty(SchemaDouble.prototype, '$conditionalHandlers', {
|
|
|
225
224
|
/**
|
|
226
225
|
* Returns this schema type's representation in a JSON schema.
|
|
227
226
|
*
|
|
228
|
-
* @param [options]
|
|
229
|
-
* @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
230
|
-
* @returns {
|
|
227
|
+
* @param {object} [options]
|
|
228
|
+
* @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
229
|
+
* @returns {object} JSON schema properties
|
|
231
230
|
*/
|
|
232
231
|
|
|
233
232
|
SchemaDouble.prototype.toJSONSchema = function toJSONSchema(options) {
|
|
234
|
-
|
|
235
|
-
return createJSONSchemaTypeDefinition('number', 'double', options?.useBsonType, isRequired);
|
|
233
|
+
return this._createJSONSchemaTypeDefinition('number', 'double', options);
|
|
236
234
|
};
|
|
237
235
|
|
|
238
236
|
SchemaDouble.prototype.autoEncryptionType = function autoEncryptionType() {
|
|
@@ -12,6 +12,7 @@ exports.Buffer = require('./buffer');
|
|
|
12
12
|
exports.Date = require('./date');
|
|
13
13
|
exports.Decimal128 = exports.Decimal = require('./decimal128');
|
|
14
14
|
exports.DocumentArray = require('./documentArray');
|
|
15
|
+
exports.DocumentArrayElement = require('./documentArrayElement');
|
|
15
16
|
exports.Double = require('./double');
|
|
16
17
|
exports.Int32 = require('./int32');
|
|
17
18
|
exports.Map = require('./map');
|