@nullix/zod-mongoose-studio 1.0.13 → 2.1.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/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/8b851c04-1848-472a-b5cd-0727aaaf90f4.json +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +232 -232
- package/.output/server/chunks/routes/api/parse.post.mjs +54 -11
- package/.output/server/chunks/routes/api/parse.post.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/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
|
@@ -10,17 +10,16 @@ const MongooseError = require('./mongooseError');
|
|
|
10
10
|
* Constructor for errors that happen when a parameter that's expected to be
|
|
11
11
|
* an object isn't an object
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {any} value
|
|
14
|
+
* @param {string} paramName
|
|
15
|
+
* @param {string} fnName
|
|
16
16
|
* @api private
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
class ObjectParameterError extends MongooseError {
|
|
20
|
-
|
|
21
20
|
constructor(value, paramName, fnName) {
|
|
22
21
|
super('Parameter "' + paramName + '" to ' + fnName +
|
|
23
|
-
'() must be an object, got "' + (value
|
|
22
|
+
'() must be an object, got "' + (value == null ? value : value.toString()) + '" (type ' + typeof value + ')');
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -40,8 +40,8 @@ class SetOptionError extends MongooseError {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* add message
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
43
|
+
* @param {string} key
|
|
44
|
+
* @param {string|Error} error
|
|
45
45
|
* @api private
|
|
46
46
|
*/
|
|
47
47
|
addError(key, error) {
|
|
@@ -87,7 +87,7 @@ Object.defineProperty(SetOptionError.prototype, 'name', {
|
|
|
87
87
|
class SetOptionInnerError extends MongooseError {
|
|
88
88
|
/**
|
|
89
89
|
* Error for the "errors" array in "SetOptionError" with consistent message
|
|
90
|
-
* @param {
|
|
90
|
+
* @param {string} key
|
|
91
91
|
*/
|
|
92
92
|
constructor(key) {
|
|
93
93
|
super(`"${key}" is not a valid option to set`);
|
|
@@ -9,9 +9,9 @@ const MongooseError = require('./mongooseError');
|
|
|
9
9
|
/**
|
|
10
10
|
* Strict mode error constructor
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
12
|
+
* @param {string} path
|
|
13
|
+
* @param {string} [msg]
|
|
14
|
+
* @param {boolean} [immutable]
|
|
15
15
|
* @inherits MongooseError
|
|
16
16
|
* @api private
|
|
17
17
|
*/
|
|
@@ -9,8 +9,8 @@ const MongooseError = require('./mongooseError');
|
|
|
9
9
|
/**
|
|
10
10
|
* SyncIndexes Error constructor.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {string} message
|
|
13
|
+
* @param {string} errorsMap
|
|
14
14
|
* @inherits MongooseError
|
|
15
15
|
* @api private
|
|
16
16
|
*/
|
|
@@ -44,18 +44,10 @@ class ValidationError extends MongooseError {
|
|
|
44
44
|
return this.name + ': ' + combinePathErrors(this);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* inspect helper
|
|
49
|
-
* @api private
|
|
50
|
-
*/
|
|
51
|
-
inspect() {
|
|
52
|
-
return Object.assign(new Error(this.message), this);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
47
|
/**
|
|
56
48
|
* add message
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
49
|
+
* @param {string} path
|
|
50
|
+
* @param {string|Error} error
|
|
59
51
|
* @api private
|
|
60
52
|
*/
|
|
61
53
|
addError(path, error) {
|
|
@@ -10,8 +10,8 @@ const MongooseError = require('./mongooseError');
|
|
|
10
10
|
* Version Error constructor.
|
|
11
11
|
*
|
|
12
12
|
* @param {Document} doc
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {number} currentVersion
|
|
14
|
+
* @param {string[]} modifiedPaths
|
|
15
15
|
* @api private
|
|
16
16
|
*/
|
|
17
17
|
|
package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = function prepareDiscriminatorPipeline(pipeline, schema, prefix) {
|
|
4
|
-
const discriminatorMapping = schema
|
|
4
|
+
const discriminatorMapping = schema?.discriminatorMapping;
|
|
5
5
|
prefix = prefix || '';
|
|
6
6
|
|
|
7
7
|
if (discriminatorMapping && !discriminatorMapping.isRoot) {
|
|
@@ -18,12 +18,12 @@ module.exports = function prepareDiscriminatorPipeline(pipeline, schema, prefix)
|
|
|
18
18
|
originalPipeline[0].$match[filterKey] = discriminatorValue;
|
|
19
19
|
// `originalPipeline` is a ref, so there's no need for
|
|
20
20
|
// aggregate._pipeline = originalPipeline
|
|
21
|
-
} else if (originalPipeline[0]
|
|
21
|
+
} else if (originalPipeline[0]?.$geoNear) {
|
|
22
22
|
originalPipeline[0].$geoNear.query =
|
|
23
23
|
originalPipeline[0].$geoNear.query || {};
|
|
24
24
|
originalPipeline[0].$geoNear.query[filterKey] = discriminatorValue;
|
|
25
|
-
} else if (originalPipeline[0]
|
|
26
|
-
if (originalPipeline[1]
|
|
25
|
+
} else if (originalPipeline[0]?.$search) {
|
|
26
|
+
if (originalPipeline[1]?.$match != null) {
|
|
27
27
|
originalPipeline[1].$match[filterKey] = originalPipeline[1].$match[filterKey] || discriminatorValue;
|
|
28
28
|
} else {
|
|
29
29
|
const match = {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const symbols = require('../schema/symbols');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Filter predicate that returns true for built-in middleware (marked with `builtInMiddleware` symbol).
|
|
7
|
+
*/
|
|
8
|
+
const isBuiltInMiddleware = hook => hook.fn[symbols.builtInMiddleware];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds a filter for kareem's execPre/execPost based on middleware options.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} options - Options object that may contain `middleware` setting
|
|
14
|
+
* @param {string} phase - Either 'pre' or 'post'
|
|
15
|
+
* @returns {Function|null} - null runs all middleware, isBuiltInMiddleware skips user middleware
|
|
16
|
+
*/
|
|
17
|
+
function buildMiddlewareFilter(options, phase) {
|
|
18
|
+
const shouldRun = options?.middleware?.[phase] ?? options?.middleware ?? true;
|
|
19
|
+
return shouldRun ? null : isBuiltInMiddleware;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
buildMiddlewareFilter
|
|
24
|
+
};
|
|
@@ -11,10 +11,10 @@ const isObject = require('./isObject');
|
|
|
11
11
|
const isPOJO = require('./isPOJO');
|
|
12
12
|
const symbols = require('./symbols');
|
|
13
13
|
const trustedSymbol = require('./query/trusted').trustedSymbol;
|
|
14
|
-
const BSON = require('bson');
|
|
14
|
+
const BSON = require('mongodb/lib/bson');
|
|
15
|
+
const UUID = BSON.UUID;
|
|
15
16
|
|
|
16
17
|
const Binary = BSON.Binary;
|
|
17
|
-
const UUID = BSON.UUID;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Object clone with Mongoose natives support.
|
|
@@ -23,10 +23,10 @@ const UUID = BSON.UUID;
|
|
|
23
23
|
*
|
|
24
24
|
* Functions and primitives are never cloned.
|
|
25
25
|
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @return {
|
|
26
|
+
* @param {object} obj the object to clone
|
|
27
|
+
* @param {object} options
|
|
28
|
+
* @param {boolean} isArrayChild true if cloning immediately underneath an array. Special case for minimize.
|
|
29
|
+
* @return {object} the cloned object
|
|
30
30
|
* @api private
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -83,7 +83,7 @@ function clone(obj, options, isArrayChild) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
let ret;
|
|
86
|
-
if (options
|
|
86
|
+
if (options?.json && typeof obj.toJSON === 'function') {
|
|
87
87
|
ret = obj.toJSON(options);
|
|
88
88
|
} else {
|
|
89
89
|
ret = obj.toObject(options);
|
|
@@ -109,14 +109,14 @@ function clone(obj, options, isArrayChild) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (isBsonType(obj, 'ObjectId')) {
|
|
112
|
-
if (options
|
|
112
|
+
if (options?.flattenObjectIds) {
|
|
113
113
|
return obj.toJSON();
|
|
114
114
|
}
|
|
115
115
|
return new ObjectId(obj.id);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
if (isBsonType(obj, 'Decimal128')) {
|
|
119
|
-
if (options
|
|
119
|
+
if (options?.flattenDecimals) {
|
|
120
120
|
return obj.toJSON();
|
|
121
121
|
}
|
|
122
122
|
return Decimal.fromString(obj.toString());
|
|
@@ -141,7 +141,7 @@ function clone(obj, options, isArrayChild) {
|
|
|
141
141
|
// If we're cloning this object to go into a MongoDB command,
|
|
142
142
|
// and there's a `toBSON()` function, assume this object will be
|
|
143
143
|
// stored as a primitive in MongoDB and doesn't need to be cloned.
|
|
144
|
-
if (options
|
|
144
|
+
if (options?.bson && typeof obj.toBSON === 'function') {
|
|
145
145
|
return obj;
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -158,9 +158,9 @@ module.exports = clone;
|
|
|
158
158
|
*/
|
|
159
159
|
|
|
160
160
|
function cloneObject(obj, options, isArrayChild) {
|
|
161
|
-
const minimize = options
|
|
162
|
-
const omitUndefined = options
|
|
163
|
-
const seen = options
|
|
161
|
+
const minimize = options?.minimize;
|
|
162
|
+
const omitUndefined = options?.omitUndefined;
|
|
163
|
+
const seen = options?._seen;
|
|
164
164
|
const ret = {};
|
|
165
165
|
let hasKeys;
|
|
166
166
|
|
|
@@ -202,10 +202,15 @@ function cloneArray(arr, options) {
|
|
|
202
202
|
|
|
203
203
|
let ret = null;
|
|
204
204
|
if (options?.retainDocuments) {
|
|
205
|
+
// Use the cloned parent doc (options.parentDoc) when available so the new
|
|
206
|
+
// array is wired up to the clone, not the source. Falling back to the
|
|
207
|
+
// source's parent preserves the previous behavior for callers that don't
|
|
208
|
+
// pass parentDoc.
|
|
209
|
+
const newParent = options.parentDoc ?? (arr.isMongooseArray ? arr.$parent() : undefined);
|
|
205
210
|
if (arr.isMongooseDocumentArray) {
|
|
206
|
-
ret = new (arr.$schemaType().schema.base.Types.DocumentArray)([], arr.$path(),
|
|
211
|
+
ret = new (arr.$schemaType().schema.base.Types.DocumentArray)([], arr.$path(), newParent, arr.$schemaType());
|
|
207
212
|
} else if (arr.isMongooseArray) {
|
|
208
|
-
ret = new (arr.$parent().schema.base.Types.Array)([], arr.$path(),
|
|
213
|
+
ret = new (arr.$parent().schema.base.Types.Array)([], arr.$path(), newParent, arr.$schemaType());
|
|
209
214
|
} else {
|
|
210
215
|
ret = new Array(len);
|
|
211
216
|
}
|
|
@@ -218,9 +223,21 @@ function cloneArray(arr, options) {
|
|
|
218
223
|
// Create new options object to avoid mutating the shared options.
|
|
219
224
|
// Subdocs need parentArray to point to their own cloned array.
|
|
220
225
|
options = { ...options, parentArray: ret };
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
// Skip change-tracking while populating the freshly cloned array: every
|
|
227
|
+
// index assignment would otherwise call markModified on the cloned parent
|
|
228
|
+
// doc and (before this guard) on the source parent doc.
|
|
229
|
+
for (i = 0; i < len; ++i) {
|
|
230
|
+
const doc = clone(arr[i], options, true);
|
|
231
|
+
// Document arrays can contain null entries, so only restamp actual subdocs.
|
|
232
|
+
if (typeof doc?.$setIndex === 'function') {
|
|
233
|
+
doc.$setIndex(i);
|
|
234
|
+
}
|
|
235
|
+
ret.set(i, doc, true);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
for (i = 0; i < len; ++i) {
|
|
239
|
+
ret[i] = clone(arr[i], options, true);
|
|
240
|
+
}
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
return ret;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Module dependencies.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const Binary = require('bson').Binary;
|
|
7
|
+
const Binary = require('mongodb/lib/bson').Binary;
|
|
8
8
|
const isBsonType = require('./isBsonType');
|
|
9
9
|
const isMongooseObject = require('./isMongooseObject');
|
|
10
10
|
const MongooseError = require('../error');
|
|
@@ -35,12 +35,12 @@ function flatten(update, path, options, schema) {
|
|
|
35
35
|
result[path + key] = val;
|
|
36
36
|
|
|
37
37
|
// Avoid going into mixed paths if schema is specified
|
|
38
|
-
const keySchema = schema
|
|
39
|
-
const isNested = schema
|
|
40
|
-
if (keySchema
|
|
38
|
+
const keySchema = schema?.path?.(path + key);
|
|
39
|
+
const isNested = schema?.nested?.[path + key];
|
|
40
|
+
if (keySchema?.instance === 'Mixed') continue;
|
|
41
41
|
|
|
42
42
|
if (shouldFlatten(val)) {
|
|
43
|
-
if (options
|
|
43
|
+
if (options?.skipArrays && Array.isArray(val)) {
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
const flat = flatten(val, path + key, options, schema);
|
|
@@ -14,9 +14,9 @@ const immediate = require('../immediate');
|
|
|
14
14
|
*
|
|
15
15
|
* @param {Function} next the thunk to call to get the next document
|
|
16
16
|
* @param {Function} fn
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
17
|
+
* @param {object} options
|
|
18
|
+
* @param {number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
|
|
19
|
+
* @param {number} [options.parallel=1] maximum number of `fn` calls that Mongoose will run in parallel
|
|
20
20
|
* @param {AbortSignal} [options.signal] allow cancelling this eachAsync(). Once the abort signal is fired, `eachAsync()` will immediately fulfill the returned promise (or call the callback) and not fetch any more documents.
|
|
21
21
|
* @return {Promise}
|
|
22
22
|
* @api public
|
|
@@ -174,7 +174,7 @@ module.exports = async function eachAsync(next, fn, options) {
|
|
|
174
174
|
} catch (err) {
|
|
175
175
|
return callback(err);
|
|
176
176
|
}
|
|
177
|
-
if (
|
|
177
|
+
if (typeof maybePromise?.then === 'function') {
|
|
178
178
|
maybePromise.then(
|
|
179
179
|
function() { callback(null); },
|
|
180
180
|
function(error) {
|
|
@@ -9,7 +9,7 @@ const getDiscriminatorByValue = require('./getDiscriminatorByValue');
|
|
|
9
9
|
|
|
10
10
|
module.exports = function getConstructor(Constructor, value, defaultDiscriminatorValue) {
|
|
11
11
|
const discriminatorKey = Constructor.schema.options.discriminatorKey;
|
|
12
|
-
let discriminatorValue =
|
|
12
|
+
let discriminatorValue = value?.[discriminatorKey];
|
|
13
13
|
if (discriminatorValue == null) {
|
|
14
14
|
discriminatorValue = defaultDiscriminatorValue;
|
|
15
15
|
}
|
|
@@ -11,7 +11,7 @@ const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
module.exports = function getSchemaDiscriminatorByValue(schema, value) {
|
|
14
|
-
if (schema
|
|
14
|
+
if (schema?.discriminators == null) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
for (const key of Object.keys(schema.discriminators)) {
|
package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js
CHANGED
|
@@ -8,9 +8,9 @@ const isObject = require('../../helpers/isObject');
|
|
|
8
8
|
/**
|
|
9
9
|
* Merges `from` into `to` without overwriting existing properties.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
11
|
+
* @param {object} to
|
|
12
|
+
* @param {object} from
|
|
13
|
+
* @param {string} [path]
|
|
14
14
|
* @api private
|
|
15
15
|
*/
|
|
16
16
|
|
|
@@ -40,12 +40,17 @@ module.exports = function mergeDiscriminatorSchema(to, from, path, seen) {
|
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
if (path === 'tree' && from
|
|
43
|
+
if (path === 'tree' && from?.instanceOfSchema) {
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
if (specialProperties.has(key)) {
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
+
if (key === 'parentSchema') {
|
|
50
|
+
// Skip parentSchema to avoid merging parent schema multiple times
|
|
51
|
+
// through child paths' back-references (gh-15966)
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
49
54
|
if (to[key] == null) {
|
|
50
55
|
to[key] = from[key];
|
|
51
56
|
} else if (isObject(from[key])) {
|
|
@@ -85,7 +90,7 @@ module.exports = function mergeDiscriminatorSchema(to, from, path, seen) {
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
if (from
|
|
93
|
+
if (from?.instanceOfSchema) {
|
|
89
94
|
to.tree = Object.assign({}, from.tree, to.tree);
|
|
90
95
|
}
|
|
91
96
|
};
|
|
@@ -5,7 +5,7 @@ const isNestedProjection = require('../projection/isNestedProjection');
|
|
|
5
5
|
module.exports = function applyDefaults(doc, fields, exclude, hasIncludedChildren, isBeforeSetters, pathsToSkip, options) {
|
|
6
6
|
const paths = Object.keys(doc.$__schema.paths);
|
|
7
7
|
const plen = paths.length;
|
|
8
|
-
const skipParentChangeTracking = options
|
|
8
|
+
const skipParentChangeTracking = options?.skipParentChangeTracking;
|
|
9
9
|
|
|
10
10
|
for (let i = 0; i < plen; ++i) {
|
|
11
11
|
let def;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const handleTimestampOption = require('../schema/handleTimestampOption');
|
|
4
4
|
const mpath = require('mpath');
|
|
5
|
+
const utils = require('../../utils');
|
|
5
6
|
|
|
6
7
|
module.exports = applyTimestamps;
|
|
7
8
|
|
|
@@ -9,9 +10,9 @@ module.exports = applyTimestamps;
|
|
|
9
10
|
* Apply a given schema's timestamps to the given POJO
|
|
10
11
|
*
|
|
11
12
|
* @param {Schema} schema
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {object} obj
|
|
14
|
+
* @param {object} [options]
|
|
15
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
15
16
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
16
17
|
*/
|
|
17
18
|
|
|
@@ -28,9 +29,9 @@ function applyTimestamps(schema, obj, options) {
|
|
|
28
29
|
* Apply timestamps to any subdocuments
|
|
29
30
|
*
|
|
30
31
|
* @param {Schema} schema subdocument schema
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
32
|
+
* @param {object} res subdocument
|
|
33
|
+
* @param {object} [options]
|
|
34
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
34
35
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
35
36
|
*/
|
|
36
37
|
|
|
@@ -54,9 +55,9 @@ function applyTimestampsToChildren(schema, res, options) {
|
|
|
54
55
|
* Apply timestamps to a given document. Does not apply timestamps to subdocuments: use `applyTimestampsToChildren` instead
|
|
55
56
|
*
|
|
56
57
|
* @param {Schema} schema
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
58
|
+
* @param {object} obj
|
|
59
|
+
* @param {object} [options]
|
|
60
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
60
61
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
61
62
|
*/
|
|
62
63
|
|
|
@@ -71,7 +72,7 @@ function applyTimestampsToDoc(schema, obj, options) {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
if (schema.discriminators &&
|
|
75
|
+
if (schema.discriminators && utils.hasOwnKeys(schema.discriminators)) {
|
|
75
76
|
for (const discriminatorKey of Object.keys(schema.discriminators)) {
|
|
76
77
|
const discriminator = schema.discriminators[discriminatorKey];
|
|
77
78
|
const key = discriminator.discriminatorMapping.key;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const mpath = require('mpath');
|
|
4
|
+
const utils = require('../../utils');
|
|
4
5
|
|
|
5
6
|
module.exports = applyVirtuals;
|
|
6
7
|
|
|
@@ -8,8 +9,8 @@ module.exports = applyVirtuals;
|
|
|
8
9
|
* Apply a given schema's virtuals to a given POJO
|
|
9
10
|
*
|
|
10
11
|
* @param {Schema} schema
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {object} obj
|
|
13
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
13
14
|
* @returns
|
|
14
15
|
*/
|
|
15
16
|
|
|
@@ -41,8 +42,8 @@ function applyVirtuals(schema, obj, virtuals) {
|
|
|
41
42
|
* Apply virtuals to any subdocuments
|
|
42
43
|
*
|
|
43
44
|
* @param {Schema} schema subdocument schema
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {object} res subdocument
|
|
46
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
49
|
function applyVirtualsToChildren(schema, res, virtuals) {
|
|
@@ -76,7 +77,7 @@ function applyVirtualsToChildren(schema, res, virtuals) {
|
|
|
76
77
|
attachedVirtuals = true;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
if (virtuals
|
|
80
|
+
if (virtuals?.length && !attachedVirtuals) {
|
|
80
81
|
applyVirtualsToDoc(schema, res, virtuals);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -85,8 +86,8 @@ function applyVirtualsToChildren(schema, res, virtuals) {
|
|
|
85
86
|
* Apply virtuals to a given document. Does not apply virtuals to subdocuments: use `applyVirtualsToChildren` instead
|
|
86
87
|
*
|
|
87
88
|
* @param {Schema} schema
|
|
88
|
-
* @param {
|
|
89
|
-
* @param {
|
|
89
|
+
* @param {object} doc
|
|
90
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
90
91
|
* @returns
|
|
91
92
|
*/
|
|
92
93
|
|
|
@@ -101,7 +102,7 @@ function applyVirtualsToDoc(schema, obj, virtuals) {
|
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
if (schema.discriminators &&
|
|
105
|
+
if (schema.discriminators && utils.hasOwnKeys(schema.discriminators)) {
|
|
105
106
|
for (const discriminatorKey of Object.keys(schema.discriminators)) {
|
|
106
107
|
const discriminator = schema.discriminators[discriminatorKey];
|
|
107
108
|
const key = discriminator.discriminatorMapping.key;
|
|
@@ -133,7 +134,7 @@ function applyVirtualsToDoc(schema, obj, virtuals) {
|
|
|
133
134
|
}
|
|
134
135
|
let val = virtualType.applyGetters(cur[sp[sp.length - 1]], obj);
|
|
135
136
|
const isPopulateVirtual =
|
|
136
|
-
virtualType.options
|
|
137
|
+
virtualType.options?.ref || virtualType.options?.refPath;
|
|
137
138
|
if (isPopulateVirtual && val === undefined) {
|
|
138
139
|
if (virtualType.options.justOne) {
|
|
139
140
|
val = null;
|
|
@@ -16,7 +16,7 @@ module.exports = function cleanModifiedSubpaths(doc, path, options) {
|
|
|
16
16
|
for (const modifiedPath of Object.keys(doc.$__.activePaths.getStatePaths('modify'))) {
|
|
17
17
|
if (skipDocArrays) {
|
|
18
18
|
const schemaType = doc.$__schema.path(modifiedPath);
|
|
19
|
-
if (schemaType
|
|
19
|
+
if (schemaType?.$isMongooseDocumentArray) {
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -31,10 +31,10 @@ const noDottedPathGetOptions = Object.freeze({
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Compiles schemas.
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
34
|
+
* @param {object} tree
|
|
35
|
+
* @param {any} proto
|
|
36
|
+
* @param {string} prefix
|
|
37
|
+
* @param {object} options
|
|
38
38
|
* @api private
|
|
39
39
|
*/
|
|
40
40
|
|
|
@@ -46,7 +46,7 @@ function compile(tree, proto, prefix, options) {
|
|
|
46
46
|
const limb = tree[key];
|
|
47
47
|
|
|
48
48
|
const hasSubprops = isPOJO(limb) &&
|
|
49
|
-
|
|
49
|
+
utils.hasOwnKeys(limb) &&
|
|
50
50
|
(!limb[typeKey] || (typeKey === 'type' && isPOJO(limb.type) && limb.type.type));
|
|
51
51
|
const subprops = hasSubprops ? limb : null;
|
|
52
52
|
|
|
@@ -56,12 +56,12 @@ function compile(tree, proto, prefix, options) {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Defines the accessor named prop on the incoming prototype.
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
59
|
+
* @param {object} options
|
|
60
|
+
* @param {string} options.prop
|
|
61
|
+
* @param {boolean} options.subprops
|
|
62
|
+
* @param {any} options.prototype
|
|
63
|
+
* @param {string} [options.prefix]
|
|
64
|
+
* @param {object} options.options
|
|
65
65
|
* @api private
|
|
66
66
|
*/
|
|
67
67
|
|
|
@@ -76,6 +76,9 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
|
|
|
76
76
|
enumerable: true,
|
|
77
77
|
configurable: true,
|
|
78
78
|
get: function() {
|
|
79
|
+
if (!this.$__) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
79
82
|
const _this = this;
|
|
80
83
|
if (!this.$__.getters) {
|
|
81
84
|
this.$__.getters = {};
|
|
@@ -132,7 +135,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
|
|
|
132
135
|
writable: false,
|
|
133
136
|
value: function() {
|
|
134
137
|
return _this.get(path, null, {
|
|
135
|
-
virtuals: this
|
|
138
|
+
virtuals: this?.schema?.options?.toObject?.virtuals || null
|
|
136
139
|
});
|
|
137
140
|
}
|
|
138
141
|
});
|
|
@@ -143,7 +146,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
|
|
|
143
146
|
writable: false,
|
|
144
147
|
value: function() {
|
|
145
148
|
return _this.get(path, null, {
|
|
146
|
-
virtuals: this
|
|
149
|
+
virtuals: this?.schema?.options?.toJSON?.virtuals || null
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
});
|
|
@@ -178,7 +181,7 @@ function defineKey({ prop, subprops, prototype, prefix, options }) {
|
|
|
178
181
|
return this.$__.getters[path];
|
|
179
182
|
},
|
|
180
183
|
set: function(v) {
|
|
181
|
-
if (v
|
|
184
|
+
if (v?.$__isNested) {
|
|
182
185
|
// Convert top-level to POJO, but leave subdocs hydrated so `$set`
|
|
183
186
|
// can handle them. See gh-9293.
|
|
184
187
|
v = v.$__get();
|