@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
package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Set a populated virtual value on a document's `$$populatedVirtuals` value
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @returns {
|
|
6
|
+
* @param {object} populatedVirtuals A document's `$$populatedVirtuals`
|
|
7
|
+
* @param {string} name The virtual name
|
|
8
|
+
* @param {any} v The result of the populate query
|
|
9
|
+
* @param {object} options The populate options. This function handles `justOne` and `count` options.
|
|
10
|
+
* @returns {Document[]|Document|object|object[]} the populated virtual value that was set
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
module.exports = function setPopulatedVirtualValue(populatedVirtuals, name, v, options) {
|
|
@@ -11,7 +11,7 @@ if (typeof jest !== 'undefined' && !process.env.SUPPRESS_JEST_WARNINGS) {
|
|
|
11
11
|
'to hide this warning.');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
if (
|
|
14
|
+
if (typeof setTimeout.clock?.Date === 'function') {
|
|
15
15
|
utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' +
|
|
16
16
|
'with Jest\'s mock timers enabled. Please make sure you read ' +
|
|
17
17
|
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
|
|
@@ -31,7 +31,7 @@ function resolveOptsConflicts(pref, opts) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function setsIndexOptions(opts) {
|
|
34
|
-
const configIdx = opts.config
|
|
34
|
+
const configIdx = opts.config?.autoIndex;
|
|
35
35
|
const { autoCreate, autoIndex } = opts;
|
|
36
36
|
return !!(configIdx || autoCreate || autoIndex);
|
|
37
37
|
}
|
|
@@ -5,9 +5,9 @@ const isDefiningProjection = require('./isDefiningProjection');
|
|
|
5
5
|
/**
|
|
6
6
|
* Determines if `path` is excluded by `projection`
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @return {
|
|
8
|
+
* @param {object} projection
|
|
9
|
+
* @param {string} path
|
|
10
|
+
* @return {boolean}
|
|
11
11
|
* @api private
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Convert a string or array into a projection object
|
|
5
|
-
*
|
|
4
|
+
* Convert a string or array into a projection object. Treats `-foo` as
|
|
5
|
+
* equivalent to `foo: 0` depending on `retainMinusPaths`. If `retainMinusPaths`
|
|
6
|
+
* is true, then `-foo` will be included in the projection as `'-foo': 0`.
|
|
7
|
+
*
|
|
8
|
+
* @param {object|string|string[]} v
|
|
9
|
+
* @param {boolean} [retainMinusPaths]
|
|
10
|
+
* @return {object}
|
|
6
11
|
*/
|
|
7
12
|
|
|
8
13
|
module.exports = function parseProjection(v, retainMinusPaths) {
|
|
@@ -22,9 +27,9 @@ module.exports = function parseProjection(v, retainMinusPaths) {
|
|
|
22
27
|
if (!field) {
|
|
23
28
|
continue;
|
|
24
29
|
}
|
|
25
|
-
const include = '-'
|
|
30
|
+
const include = field.charAt(0) === '-' ? 0 : 1;
|
|
26
31
|
if (!retainMinusPaths && include === 0) {
|
|
27
|
-
field = field.
|
|
32
|
+
field = field.slice(1);
|
|
28
33
|
}
|
|
29
34
|
ret[field] = include;
|
|
30
35
|
}
|
|
@@ -146,7 +146,7 @@ function castNumberOperator(val) {
|
|
|
146
146
|
|
|
147
147
|
try {
|
|
148
148
|
return castNumber(val);
|
|
149
|
-
} catch
|
|
149
|
+
} catch {
|
|
150
150
|
throw new CastError('Number', val);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -174,7 +174,7 @@ function castIn(val, schema, strictQuery) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
return [
|
|
177
|
-
schematype
|
|
177
|
+
schematype.embeddedSchemaType.cast(search),
|
|
178
178
|
path
|
|
179
179
|
];
|
|
180
180
|
}
|
|
@@ -187,7 +187,7 @@ function castArithmetic(val) {
|
|
|
187
187
|
}
|
|
188
188
|
try {
|
|
189
189
|
return castNumber(val);
|
|
190
|
-
} catch
|
|
190
|
+
} catch {
|
|
191
191
|
throw new CastError('Number', val);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -198,7 +198,7 @@ function castArithmetic(val) {
|
|
|
198
198
|
}
|
|
199
199
|
try {
|
|
200
200
|
return castNumber(v);
|
|
201
|
-
} catch
|
|
201
|
+
} catch {
|
|
202
202
|
throw new CastError('Number', v);
|
|
203
203
|
}
|
|
204
204
|
});
|
|
@@ -229,10 +229,8 @@ function castComparison(val, schema, strictQuery) {
|
|
|
229
229
|
path = lhs[key].slice(1) + '.' + key;
|
|
230
230
|
schematype = schema.path(lhs[key].slice(1));
|
|
231
231
|
if (schematype != null) {
|
|
232
|
-
if (schematype.$
|
|
233
|
-
schematype = schematype
|
|
234
|
-
} else if (schematype.$isMongooseArray) {
|
|
235
|
-
schematype = schematype.caster;
|
|
232
|
+
if (schematype.$isMongooseArray) {
|
|
233
|
+
schematype = schematype.embeddedSchemaType;
|
|
236
234
|
}
|
|
237
235
|
}
|
|
238
236
|
}
|
|
@@ -250,13 +248,13 @@ function castComparison(val, schema, strictQuery) {
|
|
|
250
248
|
if (is$literal) {
|
|
251
249
|
try {
|
|
252
250
|
val[1] = { $literal: caster(val[1].$literal) };
|
|
253
|
-
} catch
|
|
251
|
+
} catch {
|
|
254
252
|
throw new CastError(caster.name.replace(/^cast/, ''), val[1], path + '.$literal');
|
|
255
253
|
}
|
|
256
254
|
} else {
|
|
257
255
|
try {
|
|
258
256
|
val[1] = caster(val[1]);
|
|
259
|
-
} catch
|
|
257
|
+
} catch {
|
|
260
258
|
throw new CastError(caster.name.replace(/^cast/, ''), val[1], path);
|
|
261
259
|
}
|
|
262
260
|
}
|
|
@@ -22,7 +22,7 @@ module.exports = function castFilterPath(ctx, schematype, val) {
|
|
|
22
22
|
const nested = val[$cond];
|
|
23
23
|
|
|
24
24
|
if ($cond === '$not') {
|
|
25
|
-
if (nested && schematype && !schematype.
|
|
25
|
+
if (nested && schematype && !schematype.embeddedSchemaType && !schematype.Constructor) {
|
|
26
26
|
const _keys = Object.keys(nested);
|
|
27
27
|
if (_keys.length && isOperator(_keys[0])) {
|
|
28
28
|
for (const key of Object.keys(nested)) {
|
|
@@ -39,11 +39,11 @@ const mongodbUpdateOperators = new Set([
|
|
|
39
39
|
* Casts an update op based on the given schema
|
|
40
40
|
*
|
|
41
41
|
* @param {Schema} schema
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
42
|
+
* @param {object} obj
|
|
43
|
+
* @param {object} [options]
|
|
44
|
+
* @param {boolean|'throw'} [options.strict] defaults to true
|
|
45
45
|
* @param {Query} context passed to setters
|
|
46
|
-
* @return {
|
|
46
|
+
* @return {boolean} true iff the update is non-empty
|
|
47
47
|
* @api private
|
|
48
48
|
*/
|
|
49
49
|
module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
@@ -71,7 +71,7 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
71
71
|
const discriminatorValue = filter[schema.options.discriminatorKey];
|
|
72
72
|
const byValue = getDiscriminatorByValue(context.model.discriminators, discriminatorValue);
|
|
73
73
|
schema = schema.discriminators[discriminatorValue] ||
|
|
74
|
-
|
|
74
|
+
byValue?.schema ||
|
|
75
75
|
schema;
|
|
76
76
|
} else if (schema != null &&
|
|
77
77
|
options.overwriteDiscriminatorKey &&
|
|
@@ -80,7 +80,7 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
80
80
|
const discriminatorValue = obj[schema.options.discriminatorKey];
|
|
81
81
|
const byValue = getDiscriminatorByValue(context.model.discriminators, discriminatorValue);
|
|
82
82
|
schema = schema.discriminators[discriminatorValue] ||
|
|
83
|
-
|
|
83
|
+
byValue?.schema ||
|
|
84
84
|
schema;
|
|
85
85
|
} else if (schema != null &&
|
|
86
86
|
options.overwriteDiscriminatorKey &&
|
|
@@ -90,7 +90,7 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
90
90
|
const discriminatorValue = obj.$set[schema.options.discriminatorKey];
|
|
91
91
|
const byValue = getDiscriminatorByValue(context.model.discriminators, discriminatorValue);
|
|
92
92
|
schema = schema.discriminators[discriminatorValue] ||
|
|
93
|
-
|
|
93
|
+
byValue?.schema ||
|
|
94
94
|
schema;
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -98,6 +98,10 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
98
98
|
moveImmutableProperties(schema, obj, context);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
if (obj?.$__ && typeof obj.toObject === 'function') {
|
|
102
|
+
obj = obj.toObject(internalToObjectOptions);
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
const ops = Object.keys(obj);
|
|
102
106
|
let i = ops.length;
|
|
103
107
|
const ret = {};
|
|
@@ -133,7 +137,7 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
133
137
|
const op = ops[i];
|
|
134
138
|
val = ret[op];
|
|
135
139
|
hasDollarKey = hasDollarKey || op.startsWith('$');
|
|
136
|
-
if (val
|
|
140
|
+
if (val?.$__) {
|
|
137
141
|
val = val.toObject(internalToObjectOptions);
|
|
138
142
|
ret[op] = val;
|
|
139
143
|
}
|
|
@@ -153,9 +157,9 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
|
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
|
|
156
|
-
if (
|
|
160
|
+
if (utils.hasOwnKeys(ret) === false &&
|
|
157
161
|
options.upsert &&
|
|
158
|
-
|
|
162
|
+
utils.hasOwnKeys(filter)) {
|
|
159
163
|
// Trick the driver into allowing empty upserts to work around
|
|
160
164
|
// https://github.com/mongodb/node-mongodb-native/pull/2490
|
|
161
165
|
// Shallow clone to avoid passing defaults in re: gh-13962
|
|
@@ -202,13 +206,13 @@ function castPipelineOperator(op, val) {
|
|
|
202
206
|
* according to its schema.
|
|
203
207
|
*
|
|
204
208
|
* @param {Schema} schema
|
|
205
|
-
* @param {
|
|
206
|
-
* @param {
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {
|
|
209
|
+
* @param {object} obj part of a query
|
|
210
|
+
* @param {string} op the atomic operator ($pull, $set, etc)
|
|
211
|
+
* @param {object} [options]
|
|
212
|
+
* @param {boolean|'throw'} [options.strict]
|
|
209
213
|
* @param {Query} context
|
|
210
|
-
* @param {
|
|
211
|
-
* @param {
|
|
214
|
+
* @param {object} filter
|
|
215
|
+
* @param {string} pref path prefix (internal only)
|
|
212
216
|
* @return {Bool} true if this path has keys to update
|
|
213
217
|
* @api private
|
|
214
218
|
*/
|
|
@@ -225,7 +229,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
225
229
|
|
|
226
230
|
let aggregatedError = null;
|
|
227
231
|
|
|
228
|
-
const strictMode = strict
|
|
232
|
+
const strictMode = strict ?? schema.options.strict;
|
|
229
233
|
|
|
230
234
|
while (i--) {
|
|
231
235
|
key = keys[i];
|
|
@@ -241,7 +245,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
241
245
|
schematype = _res.schematype;
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
|
-
if (schematype
|
|
248
|
+
if (schematype?.schema != null) {
|
|
245
249
|
obj[key] = cast(schematype.schema, obj[key], options, context);
|
|
246
250
|
hasKeys = true;
|
|
247
251
|
continue;
|
|
@@ -281,7 +285,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
281
285
|
continue;
|
|
282
286
|
}
|
|
283
287
|
|
|
284
|
-
if (schematype && schematype.
|
|
288
|
+
if (schematype && (schematype.embeddedSchemaType || schematype.Constructor) && op in castOps) {
|
|
285
289
|
// embedded doc schema
|
|
286
290
|
if ('$each' in val) {
|
|
287
291
|
hasKeys = true;
|
|
@@ -305,7 +309,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
305
309
|
obj[key].$position = castNumber(val.$position);
|
|
306
310
|
}
|
|
307
311
|
} else {
|
|
308
|
-
if (schematype
|
|
312
|
+
if (schematype?.$isSingleNested) {
|
|
309
313
|
const _strict = strict == null ? schematype.schema.options.strict : strict;
|
|
310
314
|
try {
|
|
311
315
|
obj[key] = schematype.castForQuery(null, val, context, { strict: _strict });
|
|
@@ -359,7 +363,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
359
363
|
const pathToCheck = (prefix + key);
|
|
360
364
|
const v = schema._getPathType(pathToCheck);
|
|
361
365
|
let _strict = strict;
|
|
362
|
-
if (v
|
|
366
|
+
if (v?.schema && _strict == null) {
|
|
363
367
|
_strict = v.schema.options.strict;
|
|
364
368
|
}
|
|
365
369
|
|
|
@@ -376,7 +380,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
376
380
|
// we should be able to set a schema-less field
|
|
377
381
|
// to an empty object literal
|
|
378
382
|
hasKeys |= walkUpdatePath(schema, val, op, options, context, filter, prefix + key) ||
|
|
379
|
-
(utils.isObject(val) &&
|
|
383
|
+
(utils.isObject(val) && utils.hasOwnKeys(val) === false);
|
|
380
384
|
}
|
|
381
385
|
} else {
|
|
382
386
|
const isModifier = (key === '$each' || key === '$or' || key === '$and' || key === '$in');
|
|
@@ -407,7 +411,7 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
407
411
|
}
|
|
408
412
|
|
|
409
413
|
let isStrict = strict;
|
|
410
|
-
if (pathDetails
|
|
414
|
+
if (pathDetails?.schema && strict == null) {
|
|
411
415
|
isStrict = pathDetails.schema.options.strict;
|
|
412
416
|
}
|
|
413
417
|
|
|
@@ -449,9 +453,9 @@ function walkUpdatePath(schema, obj, op, options, context, filter, prefix) {
|
|
|
449
453
|
|
|
450
454
|
if (Array.isArray(obj[key]) && (op === '$addToSet' || op === '$push') && key !== '$each') {
|
|
451
455
|
if (schematype &&
|
|
452
|
-
schematype.
|
|
453
|
-
!schematype.
|
|
454
|
-
!schematype.
|
|
456
|
+
schematype.embeddedSchemaType &&
|
|
457
|
+
!schematype.embeddedSchemaType.$isMongooseArray &&
|
|
458
|
+
!schematype.embeddedSchemaType[schemaMixedSymbol]) {
|
|
455
459
|
obj[key] = { $each: obj[key] };
|
|
456
460
|
}
|
|
457
461
|
}
|
|
@@ -532,11 +536,11 @@ const overwriteOps = {
|
|
|
532
536
|
* Casts `val` according to `schema` and atomic `op`.
|
|
533
537
|
*
|
|
534
538
|
* @param {SchemaType} schema
|
|
535
|
-
* @param {
|
|
536
|
-
* @param {
|
|
537
|
-
* @param {
|
|
539
|
+
* @param {object} val
|
|
540
|
+
* @param {string} op the atomic operator ($pull, $set, etc)
|
|
541
|
+
* @param {string} $conditional
|
|
538
542
|
* @param {Query} context
|
|
539
|
-
* @param {
|
|
543
|
+
* @param {string} path
|
|
540
544
|
* @api private
|
|
541
545
|
*/
|
|
542
546
|
|
|
@@ -546,17 +550,16 @@ function castUpdateVal(schema, val, op, $conditional, context, path) {
|
|
|
546
550
|
if (op in numberOps) {
|
|
547
551
|
try {
|
|
548
552
|
return castNumber(val);
|
|
549
|
-
} catch
|
|
553
|
+
} catch {
|
|
550
554
|
throw new CastError('number', val, path);
|
|
551
555
|
}
|
|
552
556
|
}
|
|
553
557
|
return val;
|
|
554
558
|
}
|
|
555
559
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
(utils.isObject(val) || Array.isArray(val));
|
|
560
|
+
const cond = schema.$isMongooseArray
|
|
561
|
+
&& op in castOps
|
|
562
|
+
&& (utils.isObject(val) || Array.isArray(val));
|
|
560
563
|
if (cond && !overwriteOps[op]) {
|
|
561
564
|
// Cast values for ops that add data to MongoDB.
|
|
562
565
|
// Ensures embedded documents get ObjectIds etc.
|
|
@@ -564,7 +567,7 @@ function castUpdateVal(schema, val, op, $conditional, context, path) {
|
|
|
564
567
|
let cur = schema;
|
|
565
568
|
while (cur.$isMongooseArray) {
|
|
566
569
|
++schemaArrayDepth;
|
|
567
|
-
cur = cur.
|
|
570
|
+
cur = cur.embeddedSchemaType;
|
|
568
571
|
}
|
|
569
572
|
let arrayDepth = 0;
|
|
570
573
|
let _val = val;
|
|
@@ -605,7 +608,7 @@ function castUpdateVal(schema, val, op, $conditional, context, path) {
|
|
|
605
608
|
}
|
|
606
609
|
try {
|
|
607
610
|
return castNumber(val);
|
|
608
|
-
} catch
|
|
611
|
+
} catch {
|
|
609
612
|
throw new CastError('number', val, schema.path);
|
|
610
613
|
}
|
|
611
614
|
}
|
|
@@ -625,7 +628,10 @@ function castUpdateVal(schema, val, op, $conditional, context, path) {
|
|
|
625
628
|
}
|
|
626
629
|
|
|
627
630
|
if (overwriteOps[op]) {
|
|
628
|
-
const skipQueryCastForUpdate = val != null
|
|
631
|
+
const skipQueryCastForUpdate = val != null
|
|
632
|
+
&& schema.$isMongooseArray
|
|
633
|
+
&& schema.$fullPath != null
|
|
634
|
+
&& !schema.$fullPath.match(/\d+$/);
|
|
629
635
|
const applySetters = schema[schemaMixedSymbol] != null;
|
|
630
636
|
if (skipQueryCastForUpdate || applySetters) {
|
|
631
637
|
return schema.applySetters(val, context);
|
package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js
CHANGED
|
@@ -9,10 +9,10 @@ const updatedPathsByArrayFilter = require('../update/updatedPathsByArrayFilter')
|
|
|
9
9
|
* Like `schema.path()`, except with a document, because impossible to
|
|
10
10
|
* determine path type without knowing the embedded discriminator key.
|
|
11
11
|
* @param {Schema} schema
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
12
|
+
* @param {object} [update]
|
|
13
|
+
* @param {object} [filter]
|
|
14
|
+
* @param {string} path
|
|
15
|
+
* @param {object} [options]
|
|
16
16
|
* @api private
|
|
17
17
|
*/
|
|
18
18
|
|
|
@@ -23,7 +23,7 @@ module.exports = function getEmbeddedDiscriminatorPath(schema, update, filter, p
|
|
|
23
23
|
|
|
24
24
|
filter = filter || {};
|
|
25
25
|
update = update || {};
|
|
26
|
-
const arrayFilters =
|
|
26
|
+
const arrayFilters = Array.isArray(options?.arrayFilters) ?
|
|
27
27
|
options.arrayFilters : [];
|
|
28
28
|
const updatedPathsByFilter = updatedPathsByArrayFilter(update);
|
|
29
29
|
let startIndex = 0;
|
|
@@ -82,14 +82,14 @@ module.exports = function getEmbeddedDiscriminatorPath(schema, update, filter, p
|
|
|
82
82
|
continue;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const discriminator = getDiscriminatorByValue(schematype.
|
|
86
|
-
const discriminatorSchema = discriminator
|
|
85
|
+
const discriminator = getDiscriminatorByValue(schematype.Constructor.discriminators, discriminatorKey);
|
|
86
|
+
const discriminatorSchema = discriminator?.schema;
|
|
87
87
|
if (discriminatorSchema == null) {
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const rest = parts.slice(i + 1).join('.');
|
|
92
|
-
schematype = discriminatorSchema.
|
|
92
|
+
schematype = discriminatorSchema._getSchema(rest);
|
|
93
93
|
schema = discriminatorSchema;
|
|
94
94
|
startIndex = i + 1;
|
|
95
95
|
if (schematype != null) {
|
|
@@ -6,17 +6,17 @@ const StrictModeError = require('../../error/strict');
|
|
|
6
6
|
* Handle immutable option for a given path when casting updates based on options
|
|
7
7
|
*
|
|
8
8
|
* @param {SchemaType} schematype the resolved schematype for this path
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
9
|
+
* @param {boolean | 'throw' | null} strict whether strict mode is set for this query
|
|
10
|
+
* @param {object} obj the object containing the value being checked so we can delete
|
|
11
|
+
* @param {string} key the key in `obj` which we are checking for immutability
|
|
12
|
+
* @param {string} fullPath the full path being checked
|
|
13
|
+
* @param {object} options the query options
|
|
14
14
|
* @param {Query} ctx the query. Passed as `this` and first param to the `immutable` option, if `immutable` is a function
|
|
15
|
-
* @returns true if field was removed, false otherwise
|
|
15
|
+
* @returns {boolean} true if field was removed, false otherwise
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
module.exports = function handleImmutable(schematype, strict, obj, key, fullPath, options, ctx) {
|
|
19
|
-
if (
|
|
19
|
+
if (!schematype?.options?.immutable) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
let immutable = schematype.options.immutable;
|
|
@@ -28,7 +28,7 @@ module.exports = function handleImmutable(schematype, strict, obj, key, fullPath
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (options
|
|
31
|
+
if (options?.overwriteImmutable) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
if (strict === false) {
|
|
@@ -6,7 +6,7 @@ module.exports = function applyPlugins(schema, plugins, options, cacheKey) {
|
|
|
6
6
|
}
|
|
7
7
|
schema[cacheKey] = true;
|
|
8
8
|
|
|
9
|
-
if (!options
|
|
9
|
+
if (!options?.skipTopLevel) {
|
|
10
10
|
let pluginTags = null;
|
|
11
11
|
for (const plugin of plugins) {
|
|
12
12
|
const tags = plugin[1] == null ? null : plugin[1].tags;
|
|
@@ -33,7 +33,7 @@ module.exports = function applyPlugins(schema, plugins, options, cacheKey) {
|
|
|
33
33
|
applyPlugins(type.schema, plugins, options, cacheKey);
|
|
34
34
|
|
|
35
35
|
// Recompile schema because plugins may have changed it, see gh-7572
|
|
36
|
-
type.
|
|
36
|
+
type.Constructor.prototype.$__setSchema(type.schema);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -9,7 +9,7 @@ module.exports = function applyReadConcern(schema, options) {
|
|
|
9
9
|
// because you shouldn't set read concern on individual operations
|
|
10
10
|
// within a transaction.
|
|
11
11
|
// See: https://www.mongodb.com/docs/manual/reference/read-concern/
|
|
12
|
-
if (options
|
|
12
|
+
if (options?.session?.transaction) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const utils = require('../../utils');
|
|
4
|
+
|
|
3
5
|
module.exports = function applyWriteConcern(schema, options) {
|
|
4
6
|
if (options.writeConcern != null) {
|
|
5
7
|
return;
|
|
@@ -7,11 +9,11 @@ module.exports = function applyWriteConcern(schema, options) {
|
|
|
7
9
|
// Don't apply default write concern to operations in transactions,
|
|
8
10
|
// because setting write concern on an operation in a transaction is an error
|
|
9
11
|
// See: https://www.mongodb.com/docs/manual/reference/write-concern/
|
|
10
|
-
if (options
|
|
12
|
+
if (options?.session?.transaction) {
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
const writeConcern = schema.options.writeConcern ?? {};
|
|
14
|
-
if (
|
|
16
|
+
if (utils.hasOwnKeys(writeConcern)) {
|
|
15
17
|
options.writeConcern = {};
|
|
16
18
|
if (!('w' in options) && writeConcern.w != null) {
|
|
17
19
|
options.writeConcern.w = writeConcern.w;
|
|
@@ -67,9 +67,9 @@ module.exports = function getIndexes(schema) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const index = path._index || (path.
|
|
70
|
+
const index = path._index || (path.embeddedSchemaType && path.embeddedSchemaType._index);
|
|
71
71
|
|
|
72
|
-
if (index !== false && index
|
|
72
|
+
if (index !== false && index != null) {
|
|
73
73
|
const field = {};
|
|
74
74
|
const isObject = helperIsObject(index);
|
|
75
75
|
const options = isObject ? { ...index } : {};
|
|
@@ -96,14 +96,11 @@ module.exports = function getIndexes(schema) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
delete options.type;
|
|
99
|
-
if (!('background' in options)) {
|
|
100
|
-
options.background = true;
|
|
101
|
-
}
|
|
102
99
|
if (schema.options.autoIndex != null) {
|
|
103
100
|
options._autoIndex = schema.options.autoIndex;
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
const indexName = options
|
|
103
|
+
const indexName = options?.name;
|
|
107
104
|
|
|
108
105
|
if (typeof indexName === 'string') {
|
|
109
106
|
if (indexByName.has(indexName)) {
|
|
@@ -126,9 +123,6 @@ module.exports = function getIndexes(schema) {
|
|
|
126
123
|
} else {
|
|
127
124
|
schema._indexes.forEach(function(index) {
|
|
128
125
|
const options = index[1];
|
|
129
|
-
if (!('background' in options)) {
|
|
130
|
-
options.background = true;
|
|
131
|
-
}
|
|
132
126
|
decorateDiscriminatorIndexOptions(schema, options);
|
|
133
127
|
});
|
|
134
128
|
indexes = indexes.concat(schema._indexes);
|
|
@@ -141,7 +135,7 @@ module.exports = function getIndexes(schema) {
|
|
|
141
135
|
*
|
|
142
136
|
* schema._indexes = [ [indexObj, options], [indexObj, options] ..]
|
|
143
137
|
* @param {Schema} schema
|
|
144
|
-
* @param {
|
|
138
|
+
* @param {string} prefix
|
|
145
139
|
* @api private
|
|
146
140
|
*/
|
|
147
141
|
|
|
@@ -162,7 +156,7 @@ module.exports = function getIndexes(schema) {
|
|
|
162
156
|
}
|
|
163
157
|
|
|
164
158
|
const newIndexOptions = Object.assign({}, indexOptions);
|
|
165
|
-
if (indexOptions
|
|
159
|
+
if (indexOptions?.partialFilterExpression != null) {
|
|
166
160
|
newIndexOptions.partialFilterExpression = {};
|
|
167
161
|
const partialFilterExpression = indexOptions.partialFilterExpression;
|
|
168
162
|
for (const key of Object.keys(partialFilterExpression)) {
|
package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* default, not the top-level document's.
|
|
8
8
|
*
|
|
9
9
|
* @param {Schema} schema
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {string[]} parts
|
|
11
11
|
* @returns {boolean | 'throw' | undefined}
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ module.exports = function getSubdocumentStrictValue(schema, parts) {
|
|
|
19
19
|
let strict = undefined;
|
|
20
20
|
for (let i = 0; i < parts.length - 1; ++i) {
|
|
21
21
|
const curSchemaType = schema.path(cur);
|
|
22
|
-
if (curSchemaType
|
|
22
|
+
if (curSchemaType?.schema) {
|
|
23
23
|
strict = curSchemaType.schema.options.strict;
|
|
24
24
|
schema = curSchemaType.schema;
|
|
25
25
|
cur = curSchemaType.$isMongooseDocumentArray && !isNaN(parts[i + 1]) ? '' : parts[i + 1];
|