@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
|
@@ -19,7 +19,7 @@ const isPathSelectedInclusive = require('./helpers/projection/isPathSelectedIncl
|
|
|
19
19
|
* version
|
|
20
20
|
*
|
|
21
21
|
* @param {Query} query
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {object} options
|
|
23
23
|
* @return {Array}
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -30,11 +30,11 @@ exports.preparePopulationOptionsMQ = function preparePopulationOptionsMQ(query,
|
|
|
30
30
|
// lean options should trickle through all queries
|
|
31
31
|
if (options.lean != null) {
|
|
32
32
|
pop
|
|
33
|
-
.filter(p =>
|
|
33
|
+
.filter(p => p?.options?.lean == null)
|
|
34
34
|
.forEach(makeLean(options.lean));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const session = query
|
|
37
|
+
const session = query?.options?.session || null;
|
|
38
38
|
if (session != null) {
|
|
39
39
|
pop.forEach(path => {
|
|
40
40
|
if (path.options == null) {
|
|
@@ -69,8 +69,8 @@ exports.preparePopulationOptionsMQ = function preparePopulationOptionsMQ(query,
|
|
|
69
69
|
* it returns an instance of the given model.
|
|
70
70
|
*
|
|
71
71
|
* @param {Model} model
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
72
|
+
* @param {object} doc
|
|
73
|
+
* @param {object} fields
|
|
74
74
|
*
|
|
75
75
|
* @return {Document}
|
|
76
76
|
*/
|
|
@@ -80,32 +80,33 @@ exports.createModel = function createModel(model, doc, fields, userProvidedField
|
|
|
80
80
|
model.schema.discriminatorMapping :
|
|
81
81
|
null;
|
|
82
82
|
|
|
83
|
-
const key = discriminatorMapping
|
|
83
|
+
const key = discriminatorMapping?.isRoot ?
|
|
84
84
|
discriminatorMapping.key :
|
|
85
85
|
null;
|
|
86
86
|
|
|
87
|
+
const _opts = {
|
|
88
|
+
skipId: true,
|
|
89
|
+
isNew: false,
|
|
90
|
+
willInit: true
|
|
91
|
+
};
|
|
92
|
+
if (options?.defaults != null) {
|
|
93
|
+
_opts.defaults = options.defaults;
|
|
94
|
+
}
|
|
95
|
+
if (options?.strict != null) {
|
|
96
|
+
_opts.strict = options.strict;
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
const value = doc[key];
|
|
88
100
|
if (key && value && model.discriminators) {
|
|
89
101
|
const discriminator = model.discriminators[value] || getDiscriminatorByValue(model.discriminators, value);
|
|
90
102
|
if (discriminator) {
|
|
91
103
|
const _fields = clone(userProvidedFields);
|
|
92
104
|
exports.applyPaths(_fields, discriminator.schema);
|
|
93
|
-
|
|
105
|
+
|
|
94
106
|
return new discriminator(undefined, _fields, _opts);
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
|
|
98
|
-
const _opts = {
|
|
99
|
-
skipId: true,
|
|
100
|
-
isNew: false,
|
|
101
|
-
willInit: true
|
|
102
|
-
};
|
|
103
|
-
if (options != null && 'defaults' in options) {
|
|
104
|
-
_opts.defaults = options.defaults;
|
|
105
|
-
}
|
|
106
|
-
if (options != null && 'strict' in options) {
|
|
107
|
-
_opts.strict = options.strict;
|
|
108
|
-
}
|
|
109
110
|
return new model(undefined, fields, _opts);
|
|
110
111
|
};
|
|
111
112
|
|
|
@@ -114,9 +115,13 @@ exports.createModel = function createModel(model, doc, fields, userProvidedField
|
|
|
114
115
|
*/
|
|
115
116
|
|
|
116
117
|
exports.createModelAndInit = function createModelAndInit(model, doc, fields, userProvidedFields, options, populatedIds, callback) {
|
|
117
|
-
const initOpts =
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const initOpts = {};
|
|
119
|
+
if (populatedIds) {
|
|
120
|
+
initOpts.populated = populatedIds;
|
|
121
|
+
}
|
|
122
|
+
if (options?.middleware != null) {
|
|
123
|
+
initOpts.middleware = options.middleware;
|
|
124
|
+
}
|
|
120
125
|
|
|
121
126
|
const casted = exports.createModel(model, doc, fields, userProvidedFields, options);
|
|
122
127
|
try {
|
|
@@ -183,10 +188,10 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
183
188
|
// inclusive, minus path is treated as equivalent to `key: 0`.
|
|
184
189
|
// But we also allow using `-name` to remove `name` from an inclusive
|
|
185
190
|
// projection if `name` has schema-level `select: true`.
|
|
186
|
-
if (
|
|
191
|
+
if (!type?.selected || exclude !== false) {
|
|
187
192
|
fields[path] = 0;
|
|
188
193
|
exclude = true;
|
|
189
|
-
} else if (type
|
|
194
|
+
} else if (type?.selected && exclude === false) {
|
|
190
195
|
// Make a note of minus paths that are overwriting paths that are
|
|
191
196
|
// included by default.
|
|
192
197
|
minusPathsToSkip.add(path);
|
|
@@ -208,10 +213,7 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
208
213
|
}
|
|
209
214
|
break;
|
|
210
215
|
case false:
|
|
211
|
-
if (schema
|
|
212
|
-
schema.paths['_id'] &&
|
|
213
|
-
schema.paths['_id'].options &&
|
|
214
|
-
schema.paths['_id'].options.select === false) {
|
|
216
|
+
if (schema?.paths['_id']?.options?.select === false) {
|
|
215
217
|
fields._id = 0;
|
|
216
218
|
}
|
|
217
219
|
|
|
@@ -264,7 +266,7 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
264
266
|
if (type.$isSchemaMap || path.endsWith('.$*')) {
|
|
265
267
|
const plusPath = '+' + path;
|
|
266
268
|
const hasPlusPath = fields && plusPath in fields;
|
|
267
|
-
if (type.options
|
|
269
|
+
if (type.options?.select === false && !hasPlusPath) {
|
|
268
270
|
excluded.push(path);
|
|
269
271
|
}
|
|
270
272
|
return;
|
|
@@ -272,7 +274,7 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
272
274
|
let addedPath = analyzePath(path, type);
|
|
273
275
|
// arrays
|
|
274
276
|
if (addedPath == null && !Array.isArray(type) && type.$isMongooseArray && !type.$isMongooseDocumentArray) {
|
|
275
|
-
addedPath = analyzePath(path, type.
|
|
277
|
+
addedPath = analyzePath(path, type.embeddedSchemaType);
|
|
276
278
|
}
|
|
277
279
|
if (addedPath != null) {
|
|
278
280
|
addedPaths.push(addedPath);
|
|
@@ -356,7 +358,7 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
356
358
|
// Special case: if user has included a parent path of a discriminator key,
|
|
357
359
|
// don't explicitly project in the discriminator key because that will
|
|
358
360
|
// project out everything else under the parent path
|
|
359
|
-
if (!exclude && (type
|
|
361
|
+
if (!exclude && (type?.options?.$skipDiscriminatorCheck || false)) {
|
|
360
362
|
let cur = '';
|
|
361
363
|
for (let i = 0; i < pieces.length; ++i) {
|
|
362
364
|
cur += (cur.length === 0 ? '' : '.') + pieces[i];
|
|
@@ -375,14 +377,14 @@ exports.applyPaths = function applyPaths(fields, schema, sanitizeProjection) {
|
|
|
375
377
|
/**
|
|
376
378
|
* Set each path query option to lean
|
|
377
379
|
*
|
|
378
|
-
* @param {
|
|
380
|
+
* @param {object} option
|
|
379
381
|
*/
|
|
380
382
|
|
|
381
383
|
function makeLean(val) {
|
|
382
384
|
return function(option) {
|
|
383
385
|
option.options || (option.options = {});
|
|
384
386
|
|
|
385
|
-
if (
|
|
387
|
+
if (Array.isArray(val?.virtuals)) {
|
|
386
388
|
val = Object.assign({}, val);
|
|
387
389
|
val.virtuals = val.virtuals.
|
|
388
390
|
filter(path => typeof path === 'string' && path.startsWith(option.path + '.')).
|
|
@@ -21,23 +21,21 @@ const isOperator = require('../helpers/query/isOperator');
|
|
|
21
21
|
const util = require('util');
|
|
22
22
|
const utils = require('../utils');
|
|
23
23
|
const castToNumber = require('./operators/helpers').castToNumber;
|
|
24
|
-
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
|
|
25
24
|
const geospatial = require('./operators/geospatial');
|
|
26
25
|
const getDiscriminatorByValue = require('../helpers/discriminator/getDiscriminatorByValue');
|
|
27
26
|
|
|
28
27
|
let MongooseArray;
|
|
29
28
|
let EmbeddedDoc;
|
|
30
29
|
|
|
31
|
-
const isNestedArraySymbol = Symbol('mongoose#isNestedArray');
|
|
32
30
|
const emptyOpts = Object.freeze({});
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Array SchemaType constructor
|
|
36
34
|
*
|
|
37
|
-
* @param {
|
|
35
|
+
* @param {string} key
|
|
38
36
|
* @param {SchemaType} cast
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
37
|
+
* @param {object} options
|
|
38
|
+
* @param {object} schemaOptions
|
|
41
39
|
* @param {Schema} parentSchema
|
|
42
40
|
* @inherits SchemaType
|
|
43
41
|
* @api public
|
|
@@ -48,7 +46,7 @@ function SchemaArray(key, cast, options, schemaOptions, parentSchema) {
|
|
|
48
46
|
EmbeddedDoc || (EmbeddedDoc = require('../types').Embedded);
|
|
49
47
|
|
|
50
48
|
let typeKey = 'type';
|
|
51
|
-
if (schemaOptions
|
|
49
|
+
if (schemaOptions?.typeKey) {
|
|
52
50
|
typeKey = schemaOptions.typeKey;
|
|
53
51
|
}
|
|
54
52
|
this.schemaOptions = schemaOptions;
|
|
@@ -67,7 +65,7 @@ function SchemaArray(key, cast, options, schemaOptions, parentSchema) {
|
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
if (options
|
|
68
|
+
if (options?.ref != null && castOptions.ref == null) {
|
|
71
69
|
castOptions.ref = options.ref;
|
|
72
70
|
}
|
|
73
71
|
|
|
@@ -81,31 +79,21 @@ function SchemaArray(key, cast, options, schemaOptions, parentSchema) {
|
|
|
81
79
|
: utils.getFunctionName(cast);
|
|
82
80
|
|
|
83
81
|
const Types = require('./index.js');
|
|
84
|
-
const
|
|
82
|
+
const schemaTypeDefinition = Object.hasOwn(Types, name) ? Types[name] : cast;
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.casterConstructor[isNestedArraySymbol] = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (typeof caster === 'function' &&
|
|
93
|
-
!caster.$isArraySubdocument &&
|
|
94
|
-
!caster.$isSchemaMap) {
|
|
95
|
-
const path = this.caster instanceof EmbeddedDoc ? null : key;
|
|
96
|
-
if (caster === SchemaArray) {
|
|
97
|
-
this.caster = new caster(path, castOptions, schemaOptions, null, parentSchema);
|
|
84
|
+
if (typeof schemaTypeDefinition === 'function') {
|
|
85
|
+
if (schemaTypeDefinition === SchemaArray) {
|
|
86
|
+
this.embeddedSchemaType = new schemaTypeDefinition(key, castOptions, schemaOptions, null, parentSchema);
|
|
98
87
|
} else {
|
|
99
|
-
this.
|
|
88
|
+
this.embeddedSchemaType = new schemaTypeDefinition(key, castOptions, schemaOptions, parentSchema);
|
|
100
89
|
}
|
|
101
|
-
} else {
|
|
102
|
-
this.
|
|
103
|
-
if (!(this.
|
|
104
|
-
this.
|
|
90
|
+
} else if (schemaTypeDefinition instanceof SchemaType) {
|
|
91
|
+
this.embeddedSchemaType = schemaTypeDefinition;
|
|
92
|
+
if (!(this.embeddedSchemaType instanceof EmbeddedDoc)) {
|
|
93
|
+
this.embeddedSchemaType.path = key;
|
|
105
94
|
}
|
|
106
95
|
}
|
|
107
96
|
|
|
108
|
-
this.$embeddedSchemaType = this.caster;
|
|
109
97
|
}
|
|
110
98
|
|
|
111
99
|
this.$isMongooseArray = true;
|
|
@@ -166,13 +154,13 @@ SchemaArray.defaultOptions = {};
|
|
|
166
154
|
* #### Example:
|
|
167
155
|
*
|
|
168
156
|
* // Make all Array instances have `required` of true by default.
|
|
169
|
-
* mongoose.Schema.Array.set('required', true);
|
|
157
|
+
* mongoose.Schema.Types.Array.set('required', true);
|
|
170
158
|
*
|
|
171
159
|
* const User = mongoose.model('User', new Schema({ test: Array }));
|
|
172
160
|
* new User({ }).validateSync().errors.test.message; // Path `test` is required.
|
|
173
161
|
*
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {
|
|
162
|
+
* @param {string} option The option you'd like to set the value for
|
|
163
|
+
* @param {any} value value for option
|
|
176
164
|
* @return {undefined}
|
|
177
165
|
* @function set
|
|
178
166
|
* @api public
|
|
@@ -235,9 +223,9 @@ SchemaArray.prototype.virtuals = null;
|
|
|
235
223
|
/**
|
|
236
224
|
* Check if the given value satisfies the `required` validator.
|
|
237
225
|
*
|
|
238
|
-
* @param {
|
|
226
|
+
* @param {any} value
|
|
239
227
|
* @param {Document} doc
|
|
240
|
-
* @return {
|
|
228
|
+
* @return {boolean}
|
|
241
229
|
* @api public
|
|
242
230
|
*/
|
|
243
231
|
|
|
@@ -259,18 +247,16 @@ SchemaArray.prototype.checkRequired = function checkRequired(value, doc) {
|
|
|
259
247
|
* Adds an enum validator if this is an array of strings or numbers. Equivalent to
|
|
260
248
|
* `SchemaString.prototype.enum()` or `SchemaNumber.prototype.enum()`
|
|
261
249
|
*
|
|
262
|
-
* @param {...
|
|
250
|
+
* @param {...string|object} [args] enumeration values
|
|
263
251
|
* @return {SchemaArray} this
|
|
264
252
|
*/
|
|
265
253
|
|
|
266
254
|
SchemaArray.prototype.enum = function() {
|
|
267
255
|
let arr = this;
|
|
268
256
|
while (true) {
|
|
269
|
-
const instance = arr
|
|
270
|
-
arr.caster &&
|
|
271
|
-
arr.caster.instance;
|
|
257
|
+
const instance = arr?.embeddedSchemaType?.instance;
|
|
272
258
|
if (instance === 'Array') {
|
|
273
|
-
arr = arr.
|
|
259
|
+
arr = arr.embeddedSchemaType;
|
|
274
260
|
continue;
|
|
275
261
|
}
|
|
276
262
|
if (instance !== 'String' && instance !== 'Number') {
|
|
@@ -285,20 +271,20 @@ SchemaArray.prototype.enum = function() {
|
|
|
285
271
|
enumArray = utils.object.vals(enumArray);
|
|
286
272
|
}
|
|
287
273
|
|
|
288
|
-
arr.
|
|
274
|
+
arr.embeddedSchemaType.enum.apply(arr.embeddedSchemaType, enumArray);
|
|
289
275
|
return this;
|
|
290
276
|
};
|
|
291
277
|
|
|
292
278
|
/**
|
|
293
279
|
* Overrides the getters application for the population special-case
|
|
294
280
|
*
|
|
295
|
-
* @param {
|
|
296
|
-
* @param {
|
|
281
|
+
* @param {object} value
|
|
282
|
+
* @param {object} scope
|
|
297
283
|
* @api private
|
|
298
284
|
*/
|
|
299
285
|
|
|
300
286
|
SchemaArray.prototype.applyGetters = function(value, scope) {
|
|
301
|
-
if (scope
|
|
287
|
+
if (scope?.$__ != null && scope.$populated(this.path)) {
|
|
302
288
|
// means the object id was populated
|
|
303
289
|
return value;
|
|
304
290
|
}
|
|
@@ -308,9 +294,8 @@ SchemaArray.prototype.applyGetters = function(value, scope) {
|
|
|
308
294
|
};
|
|
309
295
|
|
|
310
296
|
SchemaArray.prototype._applySetters = function(value, scope, init, priorVal) {
|
|
311
|
-
if (this.
|
|
312
|
-
SchemaArray.options.castNonArrays
|
|
313
|
-
!this[isNestedArraySymbol]) {
|
|
297
|
+
if (this.embeddedSchemaType.$isMongooseArray &&
|
|
298
|
+
SchemaArray.options.castNonArrays) {
|
|
314
299
|
// Check nesting levels and wrap in array if necessary
|
|
315
300
|
let depth = 0;
|
|
316
301
|
let arr = this;
|
|
@@ -318,7 +303,7 @@ SchemaArray.prototype._applySetters = function(value, scope, init, priorVal) {
|
|
|
318
303
|
arr.$isMongooseArray &&
|
|
319
304
|
!arr.$isMongooseDocumentArray) {
|
|
320
305
|
++depth;
|
|
321
|
-
arr = arr.
|
|
306
|
+
arr = arr.embeddedSchemaType;
|
|
322
307
|
}
|
|
323
308
|
|
|
324
309
|
// No need to wrap empty arrays
|
|
@@ -338,9 +323,9 @@ SchemaArray.prototype._applySetters = function(value, scope, init, priorVal) {
|
|
|
338
323
|
/**
|
|
339
324
|
* Casts values for set().
|
|
340
325
|
*
|
|
341
|
-
* @param {
|
|
326
|
+
* @param {object} value
|
|
342
327
|
* @param {Document} doc document that triggers the casting
|
|
343
|
-
* @param {
|
|
328
|
+
* @param {boolean} init whether this is an initialization cast
|
|
344
329
|
* @api private
|
|
345
330
|
*/
|
|
346
331
|
|
|
@@ -388,13 +373,13 @@ SchemaArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
388
373
|
value = MongooseArray(rawValue, path, doc, this);
|
|
389
374
|
rawValue = value.__array;
|
|
390
375
|
|
|
391
|
-
if (init && doc
|
|
376
|
+
if (init && doc?.$__ != null && doc.$populated(this.path)) {
|
|
392
377
|
return value;
|
|
393
378
|
}
|
|
394
379
|
|
|
395
|
-
const caster = this.
|
|
380
|
+
const caster = this.embeddedSchemaType;
|
|
396
381
|
const isMongooseArray = caster.$isMongooseArray;
|
|
397
|
-
if (caster && this.
|
|
382
|
+
if (caster && this.embeddedSchemaType.constructor !== Mixed) {
|
|
398
383
|
try {
|
|
399
384
|
const len = rawValue.length;
|
|
400
385
|
for (i = 0; i < len; i++) {
|
|
@@ -412,6 +397,9 @@ SchemaArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
412
397
|
if (options.hydratedPopulatedDocs) {
|
|
413
398
|
opts.hydratedPopulatedDocs = options.hydratedPopulatedDocs;
|
|
414
399
|
}
|
|
400
|
+
if (options.virtuals) {
|
|
401
|
+
opts.virtuals = options.virtuals;
|
|
402
|
+
}
|
|
415
403
|
rawValue[i] = caster.applySetters(rawValue[i], doc, init, void 0, opts);
|
|
416
404
|
}
|
|
417
405
|
} catch (e) {
|
|
@@ -423,11 +411,11 @@ SchemaArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
423
411
|
return value;
|
|
424
412
|
}
|
|
425
413
|
|
|
426
|
-
const castNonArraysOption = this.options.castNonArrays
|
|
414
|
+
const castNonArraysOption = this.options.castNonArrays ?? SchemaArray.options.castNonArrays;
|
|
427
415
|
if (init || castNonArraysOption) {
|
|
428
416
|
// gh-2442: if we're loading this from the db and its not an array, mark
|
|
429
417
|
// the whole array as modified.
|
|
430
|
-
if (
|
|
418
|
+
if (doc && init) {
|
|
431
419
|
doc.markModified(this.path);
|
|
432
420
|
}
|
|
433
421
|
return this.cast([value], doc, init);
|
|
@@ -449,19 +437,18 @@ SchemaArray.prototype._castForPopulate = function _castForPopulate(value, doc) {
|
|
|
449
437
|
const rawValue = value.__array ? value.__array : value;
|
|
450
438
|
const len = rawValue.length;
|
|
451
439
|
|
|
452
|
-
|
|
453
|
-
if (caster && this.casterConstructor !== Mixed) {
|
|
440
|
+
if (this.embeddedSchemaType && this.embeddedSchemaType.constructor !== Mixed) {
|
|
454
441
|
try {
|
|
455
442
|
for (i = 0; i < len; i++) {
|
|
456
443
|
const opts = {};
|
|
457
444
|
// Perf: creating `arrayPath` is expensive for large arrays.
|
|
458
445
|
// We only need `arrayPath` if this is a nested array, so
|
|
459
446
|
// skip if possible.
|
|
460
|
-
if (
|
|
447
|
+
if (this.embeddedSchemaType.$isMongooseArray && this.embeddedSchemaType._arrayParentPath != null) {
|
|
461
448
|
opts.arrayPathIndex = i;
|
|
462
449
|
}
|
|
463
450
|
|
|
464
|
-
rawValue[i] =
|
|
451
|
+
rawValue[i] = this.embeddedSchemaType.cast(rawValue[i], doc, false, void 0, opts);
|
|
465
452
|
}
|
|
466
453
|
} catch (e) {
|
|
467
454
|
// rethrow
|
|
@@ -484,11 +471,10 @@ SchemaArray.prototype.$toObject = SchemaArray.prototype.toObject;
|
|
|
484
471
|
SchemaArray.prototype.discriminator = function(...args) {
|
|
485
472
|
let arr = this;
|
|
486
473
|
while (arr.$isMongooseArray && !arr.$isMongooseDocumentArray) {
|
|
487
|
-
arr = arr.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
474
|
+
arr = arr.embeddedSchemaType;
|
|
475
|
+
}
|
|
476
|
+
if (!arr.$isMongooseDocumentArray) {
|
|
477
|
+
throw new MongooseError('You can only add an embedded discriminator on a document array, ' + this.path + ' is a plain array');
|
|
492
478
|
}
|
|
493
479
|
return arr.discriminator(...args);
|
|
494
480
|
};
|
|
@@ -499,7 +485,7 @@ SchemaArray.prototype.discriminator = function(...args) {
|
|
|
499
485
|
|
|
500
486
|
SchemaArray.prototype.clone = function() {
|
|
501
487
|
const options = Object.assign({}, this.options);
|
|
502
|
-
const schematype = new this.constructor(this.path, this.
|
|
488
|
+
const schematype = new this.constructor(this.path, this.embeddedSchemaType, options, this.schemaOptions, this.parentSchema);
|
|
503
489
|
schematype.validators = this.validators.slice();
|
|
504
490
|
if (this.requiredValidator !== undefined) {
|
|
505
491
|
schematype.requiredValidator = this.requiredValidator;
|
|
@@ -508,30 +494,21 @@ SchemaArray.prototype.clone = function() {
|
|
|
508
494
|
};
|
|
509
495
|
|
|
510
496
|
SchemaArray.prototype._castForQuery = function(val, context) {
|
|
511
|
-
let
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (typeof val[Constructor.schema.options.discriminatorKey] === 'string' &&
|
|
519
|
-
Constructor.discriminators[val[Constructor.schema.options.discriminatorKey]]) {
|
|
520
|
-
Constructor = Constructor.discriminators[val[Constructor.schema.options.discriminatorKey]];
|
|
497
|
+
let embeddedSchemaType = this.embeddedSchemaType;
|
|
498
|
+
const discriminatorKey = embeddedSchemaType?.schema?.options?.discriminatorKey;
|
|
499
|
+
const discriminators = embeddedSchemaType?.discriminators;
|
|
500
|
+
|
|
501
|
+
if (val && discriminators && typeof discriminatorKey === 'string') {
|
|
502
|
+
if (discriminators[val[discriminatorKey]]) {
|
|
503
|
+
embeddedSchemaType = discriminators[val[discriminatorKey]];
|
|
521
504
|
} else {
|
|
522
|
-
const constructorByValue = getDiscriminatorByValue(
|
|
505
|
+
const constructorByValue = getDiscriminatorByValue(discriminators, val[discriminatorKey]);
|
|
523
506
|
if (constructorByValue) {
|
|
524
|
-
|
|
507
|
+
embeddedSchemaType = constructorByValue;
|
|
525
508
|
}
|
|
526
509
|
}
|
|
527
510
|
}
|
|
528
511
|
|
|
529
|
-
const proto = this.casterConstructor.prototype;
|
|
530
|
-
const protoCastForQuery = proto && proto.castForQuery;
|
|
531
|
-
const protoCast = proto && proto.cast;
|
|
532
|
-
const constructorCastForQuery = Constructor.castForQuery;
|
|
533
|
-
const caster = this.caster;
|
|
534
|
-
|
|
535
512
|
if (Array.isArray(val)) {
|
|
536
513
|
this.setters.reverse().forEach(setter => {
|
|
537
514
|
val = setter.call(this, val, this);
|
|
@@ -540,30 +517,10 @@ SchemaArray.prototype._castForQuery = function(val, context) {
|
|
|
540
517
|
if (utils.isObject(v) && v.$elemMatch) {
|
|
541
518
|
return v;
|
|
542
519
|
}
|
|
543
|
-
|
|
544
|
-
v = protoCastForQuery.call(caster, null, v, context);
|
|
545
|
-
return v;
|
|
546
|
-
} else if (protoCast) {
|
|
547
|
-
v = protoCast.call(caster, v);
|
|
548
|
-
return v;
|
|
549
|
-
} else if (constructorCastForQuery) {
|
|
550
|
-
v = constructorCastForQuery.call(caster, null, v, context);
|
|
551
|
-
return v;
|
|
552
|
-
}
|
|
553
|
-
if (v != null) {
|
|
554
|
-
v = new Constructor(v);
|
|
555
|
-
return v;
|
|
556
|
-
}
|
|
557
|
-
return v;
|
|
520
|
+
return embeddedSchemaType.castForQuery(null, v, context);
|
|
558
521
|
});
|
|
559
|
-
} else
|
|
560
|
-
val =
|
|
561
|
-
} else if (protoCast) {
|
|
562
|
-
val = protoCast.call(caster, val);
|
|
563
|
-
} else if (constructorCastForQuery) {
|
|
564
|
-
val = constructorCastForQuery.call(caster, null, val, context);
|
|
565
|
-
} else if (val != null) {
|
|
566
|
-
val = new Constructor(val);
|
|
522
|
+
} else {
|
|
523
|
+
val = embeddedSchemaType.castForQuery(null, val, context);
|
|
567
524
|
}
|
|
568
525
|
|
|
569
526
|
return val;
|
|
@@ -572,7 +529,7 @@ SchemaArray.prototype._castForQuery = function(val, context) {
|
|
|
572
529
|
/**
|
|
573
530
|
* Casts values for queries.
|
|
574
531
|
*
|
|
575
|
-
* @param {
|
|
532
|
+
* @param {string} $conditional
|
|
576
533
|
* @param {any} [value]
|
|
577
534
|
* @api private
|
|
578
535
|
*/
|
|
@@ -596,8 +553,8 @@ SchemaArray.prototype.castForQuery = function($conditional, val, context) {
|
|
|
596
553
|
/**
|
|
597
554
|
* Add a virtual to this array. Specifically to this array, not the individual elements.
|
|
598
555
|
*
|
|
599
|
-
* @param {
|
|
600
|
-
* @param {
|
|
556
|
+
* @param {string} name
|
|
557
|
+
* @param {object} [options]
|
|
601
558
|
* @api private
|
|
602
559
|
*/
|
|
603
560
|
|
|
@@ -629,12 +586,12 @@ function cast$all(val, context) {
|
|
|
629
586
|
return v;
|
|
630
587
|
}
|
|
631
588
|
if (v.$elemMatch != null) {
|
|
632
|
-
return { $elemMatch: cast(this.
|
|
589
|
+
return { $elemMatch: cast(this.embeddedSchemaType.schema, v.$elemMatch, null, this?.$$context) };
|
|
633
590
|
}
|
|
634
591
|
|
|
635
592
|
const o = {};
|
|
636
593
|
o[this.path] = v;
|
|
637
|
-
return cast(this.
|
|
594
|
+
return cast(this.embeddedSchemaType.schema, o, null, this?.$$context)[this.path];
|
|
638
595
|
}, this);
|
|
639
596
|
|
|
640
597
|
return this.castForQuery(null, val, context);
|
|
@@ -682,7 +639,7 @@ function createLogicalQueryOperatorHandler(op) {
|
|
|
682
639
|
|
|
683
640
|
const ret = [];
|
|
684
641
|
for (const obj of val) {
|
|
685
|
-
ret.push(cast(this.
|
|
642
|
+
ret.push(cast(this.embeddedSchemaType.schema ?? context.schema, obj, null, this?.$$context));
|
|
686
643
|
}
|
|
687
644
|
|
|
688
645
|
return ret;
|
|
@@ -719,16 +676,15 @@ handle.$in = SchemaType.prototype.$conditionalHandlers.$in;
|
|
|
719
676
|
/**
|
|
720
677
|
* Returns this schema type's representation in a JSON schema.
|
|
721
678
|
*
|
|
722
|
-
* @param [options]
|
|
723
|
-
* @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
724
|
-
* @returns {
|
|
679
|
+
* @param {object} [options]
|
|
680
|
+
* @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
|
|
681
|
+
* @returns {object} JSON schema properties
|
|
725
682
|
*/
|
|
726
683
|
|
|
727
684
|
SchemaArray.prototype.toJSONSchema = function toJSONSchema(options) {
|
|
728
685
|
const embeddedSchemaType = this.getEmbeddedSchemaType();
|
|
729
|
-
const isRequired = this.options.required && typeof this.options.required !== 'function';
|
|
730
686
|
return {
|
|
731
|
-
...
|
|
687
|
+
...this._createJSONSchemaTypeDefinition('array', 'array', options),
|
|
732
688
|
items: embeddedSchemaType.toJSONSchema(options)
|
|
733
689
|
};
|
|
734
690
|
};
|