@depup/mongoose 9.1.3-depup.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/LICENSE.md +22 -0
- package/README.md +397 -0
- package/SECURITY.md +1 -0
- package/eslint.config.mjs +198 -0
- package/index.js +64 -0
- package/lib/aggregate.js +1189 -0
- package/lib/cast/bigint.js +46 -0
- package/lib/cast/boolean.js +32 -0
- package/lib/cast/date.js +41 -0
- package/lib/cast/decimal128.js +39 -0
- package/lib/cast/double.js +50 -0
- package/lib/cast/int32.js +36 -0
- package/lib/cast/number.js +42 -0
- package/lib/cast/objectid.js +29 -0
- package/lib/cast/string.js +37 -0
- package/lib/cast/uuid.js +35 -0
- package/lib/cast.js +436 -0
- package/lib/collection.js +321 -0
- package/lib/connection.js +1855 -0
- package/lib/connectionState.js +26 -0
- package/lib/constants.js +73 -0
- package/lib/cursor/aggregationCursor.js +466 -0
- package/lib/cursor/changeStream.js +198 -0
- package/lib/cursor/queryCursor.js +622 -0
- package/lib/document.js +5521 -0
- package/lib/driver.js +15 -0
- package/lib/drivers/SPEC.md +4 -0
- package/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
- package/lib/drivers/node-mongodb-native/collection.js +393 -0
- package/lib/drivers/node-mongodb-native/connection.js +506 -0
- package/lib/drivers/node-mongodb-native/index.js +10 -0
- package/lib/error/browserMissingSchema.js +29 -0
- package/lib/error/bulkSaveIncompleteError.js +44 -0
- package/lib/error/bulkWriteError.js +41 -0
- package/lib/error/cast.js +158 -0
- package/lib/error/createCollectionsError.js +26 -0
- package/lib/error/divergentArray.js +40 -0
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/error/index.js +237 -0
- package/lib/error/invalidSchemaOption.js +32 -0
- package/lib/error/messages.js +47 -0
- package/lib/error/missingSchema.js +33 -0
- package/lib/error/mongooseError.js +13 -0
- package/lib/error/notFound.js +47 -0
- package/lib/error/objectExpected.js +31 -0
- package/lib/error/objectParameter.js +31 -0
- package/lib/error/overwriteModel.js +31 -0
- package/lib/error/parallelSave.js +33 -0
- package/lib/error/parallelValidate.js +33 -0
- package/lib/error/serverSelection.js +62 -0
- package/lib/error/setOptionError.js +103 -0
- package/lib/error/strict.js +35 -0
- package/lib/error/strictPopulate.js +31 -0
- package/lib/error/syncIndexes.js +30 -0
- package/lib/error/validation.js +97 -0
- package/lib/error/validator.js +100 -0
- package/lib/error/version.js +38 -0
- package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
- package/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
- package/lib/helpers/arrayDepth.js +33 -0
- package/lib/helpers/clone.js +204 -0
- package/lib/helpers/common.js +127 -0
- package/lib/helpers/createJSONSchemaTypeDefinition.js +24 -0
- package/lib/helpers/cursor/eachAsync.js +225 -0
- package/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
- package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
- package/lib/helpers/discriminator/getConstructor.js +29 -0
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +91 -0
- package/lib/helpers/document/applyDefaults.js +132 -0
- package/lib/helpers/document/applyTimestamps.js +106 -0
- package/lib/helpers/document/applyVirtuals.js +147 -0
- package/lib/helpers/document/cleanModifiedSubpaths.js +45 -0
- package/lib/helpers/document/compile.js +238 -0
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
- package/lib/helpers/document/handleSpreadDoc.js +35 -0
- package/lib/helpers/each.js +25 -0
- package/lib/helpers/error/combinePathErrors.js +22 -0
- package/lib/helpers/firstKey.js +8 -0
- package/lib/helpers/get.js +65 -0
- package/lib/helpers/getConstructorName.js +16 -0
- package/lib/helpers/getDefaultBulkwriteResult.js +18 -0
- package/lib/helpers/getFunctionName.js +10 -0
- package/lib/helpers/immediate.js +16 -0
- package/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
- package/lib/helpers/indexes/getRelatedIndexes.js +63 -0
- package/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
- package/lib/helpers/indexes/isIndexEqual.js +95 -0
- package/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
- package/lib/helpers/indexes/isTextIndex.js +16 -0
- package/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
- package/lib/helpers/isAsyncFunction.js +9 -0
- package/lib/helpers/isBsonType.js +15 -0
- package/lib/helpers/isMongooseObject.js +22 -0
- package/lib/helpers/isObject.js +16 -0
- package/lib/helpers/isPOJO.js +12 -0
- package/lib/helpers/isPromise.js +6 -0
- package/lib/helpers/isSimpleValidator.js +22 -0
- package/lib/helpers/minimize.js +41 -0
- package/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
- package/lib/helpers/model/applyHooks.js +140 -0
- package/lib/helpers/model/applyMethods.js +70 -0
- package/lib/helpers/model/applyStaticHooks.js +33 -0
- package/lib/helpers/model/applyStatics.js +13 -0
- package/lib/helpers/model/castBulkWrite.js +316 -0
- package/lib/helpers/model/decorateBulkWriteResult.js +8 -0
- package/lib/helpers/model/discriminator.js +265 -0
- package/lib/helpers/model/pushNestedArrayPaths.js +15 -0
- package/lib/helpers/omitUndefined.js +20 -0
- package/lib/helpers/once.js +12 -0
- package/lib/helpers/parallelLimit.js +37 -0
- package/lib/helpers/path/parentPaths.js +18 -0
- package/lib/helpers/path/setDottedPath.js +33 -0
- package/lib/helpers/pluralize.js +95 -0
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
- package/lib/helpers/populate/assignVals.js +360 -0
- package/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
- package/lib/helpers/populate/getModelsMapForPopulate.js +776 -0
- package/lib/helpers/populate/getSchemaTypes.js +228 -0
- package/lib/helpers/populate/getVirtual.js +103 -0
- package/lib/helpers/populate/leanPopulateMap.js +7 -0
- package/lib/helpers/populate/lookupLocalFields.js +40 -0
- package/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
- package/lib/helpers/populate/modelNamesFromRefPath.js +66 -0
- package/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
- package/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
- package/lib/helpers/populate/skipPopulateValue.js +10 -0
- package/lib/helpers/populate/validateRef.js +19 -0
- package/lib/helpers/printJestWarning.js +21 -0
- package/lib/helpers/processConnectionOptions.js +65 -0
- package/lib/helpers/projection/applyProjection.js +83 -0
- package/lib/helpers/projection/hasIncludedChildren.js +41 -0
- package/lib/helpers/projection/isDefiningProjection.js +18 -0
- package/lib/helpers/projection/isExclusive.js +37 -0
- package/lib/helpers/projection/isInclusive.js +39 -0
- package/lib/helpers/projection/isNestedProjection.js +8 -0
- package/lib/helpers/projection/isPathExcluded.js +40 -0
- package/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
- package/lib/helpers/projection/isSubpath.js +14 -0
- package/lib/helpers/projection/parseProjection.js +33 -0
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/helpers/query/cast$expr.js +287 -0
- package/lib/helpers/query/castFilterPath.js +54 -0
- package/lib/helpers/query/castUpdate.js +643 -0
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +103 -0
- package/lib/helpers/query/handleImmutable.js +44 -0
- package/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
- package/lib/helpers/query/hasDollarKeys.js +23 -0
- package/lib/helpers/query/isOperator.js +14 -0
- package/lib/helpers/query/sanitizeFilter.js +38 -0
- package/lib/helpers/query/sanitizeProjection.js +14 -0
- package/lib/helpers/query/selectPopulatedFields.js +62 -0
- package/lib/helpers/query/trusted.js +13 -0
- package/lib/helpers/query/validOps.js +3 -0
- package/lib/helpers/schema/addAutoId.js +7 -0
- package/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
- package/lib/helpers/schema/applyPlugins.js +55 -0
- package/lib/helpers/schema/applyReadConcern.js +20 -0
- package/lib/helpers/schema/applyWriteConcern.js +39 -0
- package/lib/helpers/schema/cleanPositionalOperators.js +12 -0
- package/lib/helpers/schema/getIndexes.js +171 -0
- package/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
- package/lib/helpers/schema/getPath.js +43 -0
- package/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/lib/helpers/schema/handleIdOption.js +20 -0
- package/lib/helpers/schema/handleTimestampOption.js +24 -0
- package/lib/helpers/schema/idGetter.js +34 -0
- package/lib/helpers/schema/merge.js +36 -0
- package/lib/helpers/schematype/handleImmutable.js +50 -0
- package/lib/helpers/setDefaultsOnInsert.js +158 -0
- package/lib/helpers/specialProperties.js +3 -0
- package/lib/helpers/symbols.js +20 -0
- package/lib/helpers/timers.js +3 -0
- package/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
- package/lib/helpers/timestamps/setupTimestamps.js +116 -0
- package/lib/helpers/topology/allServersUnknown.js +12 -0
- package/lib/helpers/topology/isAtlas.js +31 -0
- package/lib/helpers/topology/isSSLError.js +16 -0
- package/lib/helpers/update/applyTimestampsToChildren.js +193 -0
- package/lib/helpers/update/applyTimestampsToUpdate.js +131 -0
- package/lib/helpers/update/castArrayFilters.js +113 -0
- package/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
- package/lib/helpers/update/modifiedPaths.js +33 -0
- package/lib/helpers/update/moveImmutableProperties.js +53 -0
- package/lib/helpers/update/removeUnusedArrayFilters.js +32 -0
- package/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
- package/lib/helpers/updateValidators.js +193 -0
- package/lib/index.js +17 -0
- package/lib/internal.js +46 -0
- package/lib/model.js +5010 -0
- package/lib/modifiedPathsSnapshot.js +9 -0
- package/lib/mongoose.js +1411 -0
- package/lib/options/populateOptions.js +36 -0
- package/lib/options/propertyOptions.js +8 -0
- package/lib/options/saveOptions.js +16 -0
- package/lib/options/schemaArrayOptions.js +78 -0
- package/lib/options/schemaBufferOptions.js +38 -0
- package/lib/options/schemaDateOptions.js +71 -0
- package/lib/options/schemaDocumentArrayOptions.js +68 -0
- package/lib/options/schemaMapOptions.js +43 -0
- package/lib/options/schemaNumberOptions.js +101 -0
- package/lib/options/schemaObjectIdOptions.js +64 -0
- package/lib/options/schemaStringOptions.js +138 -0
- package/lib/options/schemaSubdocumentOptions.js +66 -0
- package/lib/options/schemaTypeOptions.js +244 -0
- package/lib/options/schemaUnionOptions.js +32 -0
- package/lib/options/virtualOptions.js +164 -0
- package/lib/options.js +17 -0
- package/lib/plugins/index.js +6 -0
- package/lib/plugins/saveSubdocs.js +76 -0
- package/lib/plugins/sharding.js +84 -0
- package/lib/plugins/trackTransaction.js +84 -0
- package/lib/plugins/validateBeforeSave.js +41 -0
- package/lib/query.js +5673 -0
- package/lib/queryHelpers.js +387 -0
- package/lib/schema/array.js +699 -0
- package/lib/schema/bigint.js +282 -0
- package/lib/schema/boolean.js +332 -0
- package/lib/schema/buffer.js +343 -0
- package/lib/schema/date.js +467 -0
- package/lib/schema/decimal128.js +263 -0
- package/lib/schema/documentArray.js +656 -0
- package/lib/schema/documentArrayElement.js +137 -0
- package/lib/schema/double.js +246 -0
- package/lib/schema/index.js +32 -0
- package/lib/schema/int32.js +289 -0
- package/lib/schema/map.js +201 -0
- package/lib/schema/mixed.js +146 -0
- package/lib/schema/number.js +510 -0
- package/lib/schema/objectId.js +333 -0
- package/lib/schema/operators/bitwise.js +38 -0
- package/lib/schema/operators/exists.js +12 -0
- package/lib/schema/operators/geospatial.js +107 -0
- package/lib/schema/operators/helpers.js +32 -0
- package/lib/schema/operators/text.js +39 -0
- package/lib/schema/operators/type.js +20 -0
- package/lib/schema/string.js +733 -0
- package/lib/schema/subdocument.js +436 -0
- package/lib/schema/symbols.js +5 -0
- package/lib/schema/union.js +113 -0
- package/lib/schema/uuid.js +305 -0
- package/lib/schema.js +3226 -0
- package/lib/schemaType.js +1835 -0
- package/lib/stateMachine.js +232 -0
- package/lib/types/array/index.js +119 -0
- package/lib/types/array/isMongooseArray.js +5 -0
- package/lib/types/array/methods/index.js +1095 -0
- package/lib/types/arraySubdocument.js +207 -0
- package/lib/types/buffer.js +294 -0
- package/lib/types/decimal128.js +13 -0
- package/lib/types/documentArray/index.js +113 -0
- package/lib/types/documentArray/isMongooseDocumentArray.js +5 -0
- package/lib/types/documentArray/methods/index.js +415 -0
- package/lib/types/double.js +13 -0
- package/lib/types/index.js +23 -0
- package/lib/types/map.js +419 -0
- package/lib/types/objectid.js +41 -0
- package/lib/types/subdocument.js +464 -0
- package/lib/types/uuid.js +13 -0
- package/lib/utils.js +1054 -0
- package/lib/validOptions.js +42 -0
- package/lib/virtualType.js +204 -0
- package/package.json +148 -0
- package/types/aggregate.d.ts +180 -0
- package/types/augmentations.d.ts +9 -0
- package/types/callback.d.ts +8 -0
- package/types/collection.d.ts +49 -0
- package/types/connection.d.ts +297 -0
- package/types/cursor.d.ts +67 -0
- package/types/document.d.ts +374 -0
- package/types/error.d.ts +143 -0
- package/types/expressions.d.ts +3053 -0
- package/types/helpers.d.ts +32 -0
- package/types/index.d.ts +1056 -0
- package/types/indexes.d.ts +97 -0
- package/types/inferhydrateddoctype.d.ts +115 -0
- package/types/inferrawdoctype.d.ts +135 -0
- package/types/inferschematype.d.ts +337 -0
- package/types/middlewares.d.ts +59 -0
- package/types/models.d.ts +1306 -0
- package/types/mongooseoptions.d.ts +228 -0
- package/types/pipelinestage.d.ts +333 -0
- package/types/populate.d.ts +53 -0
- package/types/query.d.ts +934 -0
- package/types/schemaoptions.d.ts +282 -0
- package/types/schematypes.d.ts +654 -0
- package/types/session.d.ts +32 -0
- package/types/types.d.ts +109 -0
- package/types/utility.d.ts +175 -0
- package/types/validation.d.ts +39 -0
- package/types/virtuals.d.ts +14 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* Module dependencies.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const MongooseError = require('./mongooseError');
|
|
8
|
+
const util = require('util');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Casting Error constructor.
|
|
12
|
+
*
|
|
13
|
+
* @param {String} type
|
|
14
|
+
* @param {String} value
|
|
15
|
+
* @inherits MongooseError
|
|
16
|
+
* @api private
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
class CastError extends MongooseError {
|
|
20
|
+
constructor(type, value, path, reason, schemaType) {
|
|
21
|
+
// If no args, assume we'll `init()` later.
|
|
22
|
+
if (arguments.length > 0) {
|
|
23
|
+
const valueType = getValueType(value);
|
|
24
|
+
const messageFormat = getMessageFormat(schemaType);
|
|
25
|
+
const msg = formatMessage(null, type, value, path, messageFormat, valueType, reason);
|
|
26
|
+
super(msg);
|
|
27
|
+
this.init(type, value, path, reason, schemaType);
|
|
28
|
+
} else {
|
|
29
|
+
super(formatMessage());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
stringValue: this.stringValue,
|
|
36
|
+
valueType: this.valueType,
|
|
37
|
+
kind: this.kind,
|
|
38
|
+
value: this.value,
|
|
39
|
+
path: this.path,
|
|
40
|
+
reason: this.reason,
|
|
41
|
+
name: this.name,
|
|
42
|
+
message: this.message
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/*!
|
|
46
|
+
* ignore
|
|
47
|
+
*/
|
|
48
|
+
init(type, value, path, reason, schemaType) {
|
|
49
|
+
this.stringValue = getStringValue(value);
|
|
50
|
+
this.messageFormat = getMessageFormat(schemaType);
|
|
51
|
+
this.kind = type;
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.path = path;
|
|
54
|
+
this.reason = reason;
|
|
55
|
+
this.valueType = getValueType(value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* ignore
|
|
60
|
+
* @param {Readonly<CastError>} other
|
|
61
|
+
* @api private
|
|
62
|
+
*/
|
|
63
|
+
copy(other) {
|
|
64
|
+
this.messageFormat = other.messageFormat;
|
|
65
|
+
this.stringValue = other.stringValue;
|
|
66
|
+
this.kind = other.kind;
|
|
67
|
+
this.value = other.value;
|
|
68
|
+
this.path = other.path;
|
|
69
|
+
this.reason = other.reason;
|
|
70
|
+
this.message = other.message;
|
|
71
|
+
this.valueType = other.valueType;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*!
|
|
75
|
+
* ignore
|
|
76
|
+
*/
|
|
77
|
+
setModel(model) {
|
|
78
|
+
this.message = formatMessage(model, this.kind, this.value, this.path,
|
|
79
|
+
this.messageFormat, this.valueType);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Object.defineProperty(CastError.prototype, 'name', {
|
|
84
|
+
value: 'CastError'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
function getStringValue(value) {
|
|
88
|
+
let stringValue = util.inspect(value);
|
|
89
|
+
stringValue = stringValue.replace(/^'|'$/g, '"');
|
|
90
|
+
if (!stringValue.startsWith('"')) {
|
|
91
|
+
stringValue = '"' + stringValue + '"';
|
|
92
|
+
}
|
|
93
|
+
return stringValue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getValueType(value) {
|
|
97
|
+
if (value == null) {
|
|
98
|
+
return '' + value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const t = typeof value;
|
|
102
|
+
if (t !== 'object') {
|
|
103
|
+
return t;
|
|
104
|
+
}
|
|
105
|
+
if (typeof value.constructor !== 'function') {
|
|
106
|
+
return t;
|
|
107
|
+
}
|
|
108
|
+
return value.constructor.name;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getMessageFormat(schemaType) {
|
|
112
|
+
const messageFormat = schemaType?._castErrorMessage || null;
|
|
113
|
+
if (typeof messageFormat === 'string' || typeof messageFormat === 'function') {
|
|
114
|
+
return messageFormat;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/*!
|
|
119
|
+
* ignore
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
function formatMessage(model, kind, value, path, messageFormat, valueType, reason) {
|
|
123
|
+
if (typeof messageFormat === 'string') {
|
|
124
|
+
const stringValue = getStringValue(value);
|
|
125
|
+
let ret = messageFormat.
|
|
126
|
+
replace('{KIND}', kind).
|
|
127
|
+
replace('{VALUE}', stringValue).
|
|
128
|
+
replace('{PATH}', path);
|
|
129
|
+
if (model != null) {
|
|
130
|
+
ret = ret.replace('{MODEL}', model.modelName);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return ret;
|
|
134
|
+
} else if (typeof messageFormat === 'function') {
|
|
135
|
+
return messageFormat(value, path, model, kind);
|
|
136
|
+
} else {
|
|
137
|
+
const stringValue = getStringValue(value);
|
|
138
|
+
const valueTypeMsg = valueType ? ' (type ' + valueType + ')' : '';
|
|
139
|
+
let ret = 'Cast to ' + kind + ' failed for value ' +
|
|
140
|
+
stringValue + valueTypeMsg + ' at path "' + path + '"';
|
|
141
|
+
if (model != null) {
|
|
142
|
+
ret += ' for model "' + model.modelName + '"';
|
|
143
|
+
}
|
|
144
|
+
if (reason != null &&
|
|
145
|
+
typeof reason.constructor === 'function' &&
|
|
146
|
+
reason.constructor.name !== 'AssertionError' &&
|
|
147
|
+
reason.constructor.name !== 'Error') {
|
|
148
|
+
ret += ' because of "' + reason.constructor.name + '"';
|
|
149
|
+
}
|
|
150
|
+
return ret;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/*!
|
|
155
|
+
* exports
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
module.exports = CastError;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const MongooseError = require('./mongooseError');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* createCollections Error constructor
|
|
7
|
+
*
|
|
8
|
+
* @param {String} message
|
|
9
|
+
* @param {String} errorsMap
|
|
10
|
+
* @inherits MongooseError
|
|
11
|
+
* @api private
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
class CreateCollectionsError extends MongooseError {
|
|
15
|
+
constructor(message, errorsMap) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.errors = errorsMap;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(CreateCollectionsError.prototype, 'name', {
|
|
22
|
+
value: 'CreateCollectionsError'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
module.exports = CreateCollectionsError;
|
|
26
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Module dependencies.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const MongooseError = require('./mongooseError');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DivergentArrayError constructor.
|
|
12
|
+
* @param {Array<String>} paths
|
|
13
|
+
* @api private
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
class DivergentArrayError extends MongooseError {
|
|
17
|
+
|
|
18
|
+
constructor(paths) {
|
|
19
|
+
const msg = 'For your own good, using `document.save()` to update an array '
|
|
20
|
+
+ 'which was selected using an $elemMatch projection OR '
|
|
21
|
+
+ 'populated using skip, limit, query conditions, or exclusion of '
|
|
22
|
+
+ 'the _id field when the operation results in a $pop or $set of '
|
|
23
|
+
+ 'the entire array is not supported. The following '
|
|
24
|
+
+ 'path(s) would have been modified unsafely:\n'
|
|
25
|
+
+ ' ' + paths.join('\n ') + '\n'
|
|
26
|
+
+ 'Use Model.updateOne() to update these arrays instead. '
|
|
27
|
+
+ 'See https://mongoosejs.com/docs/faq.html#divergent-array-error for more information.';
|
|
28
|
+
super(msg);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Object.defineProperty(DivergentArrayError.prototype, 'name', {
|
|
33
|
+
value: 'DivergentArrayError'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/*!
|
|
37
|
+
* exports
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
module.exports = DivergentArrayError;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Module dependencies.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const MongooseError = require('./mongooseError');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* If `eachAsync()` is called with `continueOnError: true`, there can be
|
|
12
|
+
* multiple errors. This error class contains an `errors` property, which
|
|
13
|
+
* contains an array of all errors that occurred in `eachAsync()`.
|
|
14
|
+
*
|
|
15
|
+
* @api private
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
class EachAsyncMultiError extends MongooseError {
|
|
19
|
+
/**
|
|
20
|
+
* @param {String} connectionString
|
|
21
|
+
*/
|
|
22
|
+
constructor(errors) {
|
|
23
|
+
let preview = errors.map(e => e.message).join(', ');
|
|
24
|
+
if (preview.length > 50) {
|
|
25
|
+
preview = preview.slice(0, 50) + '...';
|
|
26
|
+
}
|
|
27
|
+
super(`eachAsync() finished with ${errors.length} errors: ${preview}`);
|
|
28
|
+
|
|
29
|
+
this.errors = errors;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Object.defineProperty(EachAsyncMultiError.prototype, 'name', {
|
|
34
|
+
value: 'EachAsyncMultiError'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/*!
|
|
38
|
+
* exports
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
module.exports = EachAsyncMultiError;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MongooseError constructor. MongooseError is the base class for all
|
|
5
|
+
* Mongoose-specific errors.
|
|
6
|
+
*
|
|
7
|
+
* #### Example:
|
|
8
|
+
*
|
|
9
|
+
* const Model = mongoose.model('Test', new mongoose.Schema({ answer: Number }));
|
|
10
|
+
* const doc = new Model({ answer: 'not a number' });
|
|
11
|
+
* const err = doc.validateSync();
|
|
12
|
+
*
|
|
13
|
+
* err instanceof mongoose.Error.ValidationError; // true
|
|
14
|
+
*
|
|
15
|
+
* @constructor Error
|
|
16
|
+
* @param {String} msg Error message
|
|
17
|
+
* @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const MongooseError = require('./mongooseError');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The name of the error. The name uniquely identifies this Mongoose error. The
|
|
24
|
+
* possible values are:
|
|
25
|
+
*
|
|
26
|
+
* - `MongooseError`: general Mongoose error
|
|
27
|
+
* - `CastError`: Mongoose could not convert a value to the type defined in the schema path. May be in a `ValidationError` class' `errors` property.
|
|
28
|
+
* - `DivergentArrayError`: You attempted to `save()` an array that was modified after you loaded it with a `$elemMatch` or similar projection
|
|
29
|
+
* - `MissingSchemaError`: You tried to access a model with [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.model()) that was not defined
|
|
30
|
+
* - `DocumentNotFoundError`: The document you tried to [`save()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.save()) was not found
|
|
31
|
+
* - `ValidatorError`: error from an individual schema path's validator
|
|
32
|
+
* - `ValidationError`: error returned from [`validate()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()) or [`validateSync()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validateSync()). Contains zero or more `ValidatorError` instances in `.errors` property.
|
|
33
|
+
* - `MissingSchemaError`: You called `mongoose.Document()` without a schema
|
|
34
|
+
* - `ObjectExpectedError`: Thrown when you set a nested path to a non-object value with [strict mode set](https://mongoosejs.com/docs/guide.html#strict).
|
|
35
|
+
* - `ObjectParameterError`: Thrown when you pass a non-object value to a function which expects an object as a paramter
|
|
36
|
+
* - `OverwriteModelError`: Thrown when you call [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.model()) to re-define a model that was already defined.
|
|
37
|
+
* - `ParallelSaveError`: Thrown when you call [`save()`](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) on a document when the same document instance is already saving.
|
|
38
|
+
* - `StrictModeError`: Thrown when you set a path that isn't the schema and [strict mode](https://mongoosejs.com/docs/guide.html#strict) is set to `throw`.
|
|
39
|
+
* - `VersionError`: Thrown when the [document is out of sync](https://mongoosejs.com/docs/guide.html#versionKey)
|
|
40
|
+
*
|
|
41
|
+
* @api public
|
|
42
|
+
* @property {String} name
|
|
43
|
+
* @memberOf Error
|
|
44
|
+
* @instance
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/*!
|
|
48
|
+
* Module exports.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
module.exports = exports = MongooseError;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The default built-in validator error messages.
|
|
55
|
+
*
|
|
56
|
+
* @see Error.messages https://mongoosejs.com/docs/api/error.html#Error.messages
|
|
57
|
+
* @api public
|
|
58
|
+
* @memberOf Error
|
|
59
|
+
* @static
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
MongooseError.messages = require('./messages');
|
|
63
|
+
|
|
64
|
+
// backward compat
|
|
65
|
+
MongooseError.Messages = MongooseError.messages;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An instance of this error class will be thrown when mongoose failed to
|
|
69
|
+
* cast a value.
|
|
70
|
+
*
|
|
71
|
+
* @api public
|
|
72
|
+
* @memberOf Error
|
|
73
|
+
* @static
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
MongooseError.CastError = require('./cast');
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* An instance of this error class will be thrown when `save()` fails
|
|
80
|
+
* because the underlying
|
|
81
|
+
* document was not found. The constructor takes one parameter, the
|
|
82
|
+
* conditions that mongoose passed to `updateOne()` when trying to update
|
|
83
|
+
* the document.
|
|
84
|
+
*
|
|
85
|
+
* @api public
|
|
86
|
+
* @memberOf Error
|
|
87
|
+
* @static
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
MongooseError.DocumentNotFoundError = require('./notFound');
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An instance of this error class will be thrown when [validation](https://mongoosejs.com/docs/validation.html) failed.
|
|
94
|
+
* The `errors` property contains an object whose keys are the paths that failed and whose values are
|
|
95
|
+
* instances of CastError or ValidationError.
|
|
96
|
+
*
|
|
97
|
+
* @api public
|
|
98
|
+
* @memberOf Error
|
|
99
|
+
* @static
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
MongooseError.ValidationError = require('./validation');
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A `ValidationError` has a hash of `errors` that contain individual
|
|
106
|
+
* `ValidatorError` instances.
|
|
107
|
+
*
|
|
108
|
+
* #### Example:
|
|
109
|
+
*
|
|
110
|
+
* const schema = Schema({ name: { type: String, required: true } });
|
|
111
|
+
* const Model = mongoose.model('Test', schema);
|
|
112
|
+
* const doc = new Model({});
|
|
113
|
+
*
|
|
114
|
+
* // Top-level error is a ValidationError, **not** a ValidatorError
|
|
115
|
+
* const err = doc.validateSync();
|
|
116
|
+
* err instanceof mongoose.Error.ValidationError; // true
|
|
117
|
+
*
|
|
118
|
+
* // A ValidationError `err` has 0 or more ValidatorErrors keyed by the
|
|
119
|
+
* // path in the `err.errors` property.
|
|
120
|
+
* err.errors['name'] instanceof mongoose.Error.ValidatorError;
|
|
121
|
+
*
|
|
122
|
+
* err.errors['name'].kind; // 'required'
|
|
123
|
+
* err.errors['name'].path; // 'name'
|
|
124
|
+
* err.errors['name'].value; // undefined
|
|
125
|
+
*
|
|
126
|
+
* Instances of `ValidatorError` have the following properties:
|
|
127
|
+
*
|
|
128
|
+
* - `kind`: The validator's `type`, like `'required'` or `'regexp'`
|
|
129
|
+
* - `path`: The path that failed validation
|
|
130
|
+
* - `value`: The value that failed validation
|
|
131
|
+
*
|
|
132
|
+
* @api public
|
|
133
|
+
* @memberOf Error
|
|
134
|
+
* @static
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
MongooseError.ValidatorError = require('./validator');
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* An instance of this error class will be thrown when you call `save()` after
|
|
141
|
+
* the document in the database was changed in a potentially unsafe way. See
|
|
142
|
+
* the [`versionKey` option](https://mongoosejs.com/docs/guide.html#versionKey) for more information.
|
|
143
|
+
*
|
|
144
|
+
* @api public
|
|
145
|
+
* @memberOf Error
|
|
146
|
+
* @static
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
MongooseError.VersionError = require('./version');
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* An instance of this error class will be thrown when you call `save()` multiple
|
|
153
|
+
* times on the same document in parallel. See the [FAQ](https://mongoosejs.com/docs/faq.html) for more
|
|
154
|
+
* information.
|
|
155
|
+
*
|
|
156
|
+
* @api public
|
|
157
|
+
* @memberOf Error
|
|
158
|
+
* @static
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
MongooseError.ParallelSaveError = require('./parallelSave');
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Thrown when a model with the given name was already registered on the connection.
|
|
165
|
+
* See [the FAQ about `OverwriteModelError`](https://mongoosejs.com/docs/faq.html#overwrite-model-error).
|
|
166
|
+
*
|
|
167
|
+
* @api public
|
|
168
|
+
* @memberOf Error
|
|
169
|
+
* @static
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
MongooseError.OverwriteModelError = require('./overwriteModel');
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Thrown when you try to access a model that has not been registered yet
|
|
176
|
+
*
|
|
177
|
+
* @api public
|
|
178
|
+
* @memberOf Error
|
|
179
|
+
* @static
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
MongooseError.MissingSchemaError = require('./missingSchema');
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Thrown when some documents failed to save when calling `bulkSave()`
|
|
186
|
+
*
|
|
187
|
+
* @api public
|
|
188
|
+
* @memberOf Error
|
|
189
|
+
* @static
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
MongooseError.MongooseBulkSaveIncompleteError = require('./bulkSaveIncompleteError');
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Thrown when the MongoDB Node driver can't connect to a valid server
|
|
196
|
+
* to send an operation to.
|
|
197
|
+
*
|
|
198
|
+
* @api public
|
|
199
|
+
* @memberOf Error
|
|
200
|
+
* @static
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
MongooseError.MongooseServerSelectionError = require('./serverSelection');
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* An instance of this error will be thrown if you used an array projection
|
|
207
|
+
* and then modified the array in an unsafe way.
|
|
208
|
+
*
|
|
209
|
+
* @api public
|
|
210
|
+
* @memberOf Error
|
|
211
|
+
* @static
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
MongooseError.DivergentArrayError = require('./divergentArray');
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Thrown when your try to pass values to model constructor that
|
|
218
|
+
* were not specified in schema or change immutable properties when
|
|
219
|
+
* `strict` mode is `"throw"`
|
|
220
|
+
*
|
|
221
|
+
* @api public
|
|
222
|
+
* @memberOf Error
|
|
223
|
+
* @static
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
MongooseError.StrictModeError = require('./strict');
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* An instance of this error class will be returned when mongoose failed to
|
|
230
|
+
* populate with a path that is not existing.
|
|
231
|
+
*
|
|
232
|
+
* @api public
|
|
233
|
+
* @memberOf Error
|
|
234
|
+
* @static
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
MongooseError.StrictPopulateError = require('./strictPopulate');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Module dependencies.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const MongooseError = require('./mongooseError');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* InvalidSchemaOption Error constructor.
|
|
12
|
+
* @param {String} name
|
|
13
|
+
* @api private
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
class InvalidSchemaOptionError extends MongooseError {
|
|
17
|
+
|
|
18
|
+
constructor(name, option) {
|
|
19
|
+
const msg = `Cannot create use schema for property "${name}" because the schema has the ${option} option enabled.`;
|
|
20
|
+
super(msg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Object.defineProperty(InvalidSchemaOptionError.prototype, 'name', {
|
|
25
|
+
value: 'InvalidSchemaOptionError'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/*!
|
|
29
|
+
* exports
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
module.exports = InvalidSchemaOptionError;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* The default built-in validator error messages. These may be customized.
|
|
4
|
+
*
|
|
5
|
+
* // customize within each schema or globally like so
|
|
6
|
+
* const mongoose = require('mongoose');
|
|
7
|
+
* mongoose.Error.messages.String.enum = "Your custom message for {PATH}.";
|
|
8
|
+
*
|
|
9
|
+
* Error messages support basic templating. Mongoose will replace the following strings with the corresponding value.
|
|
10
|
+
*
|
|
11
|
+
* - `{PATH}` is replaced with the invalid document path
|
|
12
|
+
* - `{VALUE}` is replaced with the invalid value
|
|
13
|
+
* - `{TYPE}` is replaced with the validator type such as "regexp", "min", or "user defined"
|
|
14
|
+
* - `{MIN}` is replaced with the declared min value for the Number.min validator
|
|
15
|
+
* - `{MAX}` is replaced with the declared max value for the Number.max validator
|
|
16
|
+
*
|
|
17
|
+
* Click the "show code" link below to see all defaults.
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
* @memberOf MongooseError
|
|
21
|
+
* @api public
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
const msg = module.exports = exports = {};
|
|
27
|
+
|
|
28
|
+
msg.DocumentNotFoundError = null;
|
|
29
|
+
|
|
30
|
+
msg.general = {};
|
|
31
|
+
msg.general.default = 'Validator failed for path `{PATH}` with value `{VALUE}`';
|
|
32
|
+
msg.general.required = 'Path `{PATH}` is required.';
|
|
33
|
+
|
|
34
|
+
msg.Number = {};
|
|
35
|
+
msg.Number.min = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';
|
|
36
|
+
msg.Number.max = 'Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).';
|
|
37
|
+
msg.Number.enum = '`{VALUE}` is not a valid enum value for path `{PATH}`.';
|
|
38
|
+
|
|
39
|
+
msg.Date = {};
|
|
40
|
+
msg.Date.min = 'Path `{PATH}` ({VALUE}) is before minimum allowed value ({MIN}).';
|
|
41
|
+
msg.Date.max = 'Path `{PATH}` ({VALUE}) is after maximum allowed value ({MAX}).';
|
|
42
|
+
|
|
43
|
+
msg.String = {};
|
|
44
|
+
msg.String.enum = '`{VALUE}` is not a valid enum value for path `{PATH}`.';
|
|
45
|
+
msg.String.match = 'Path `{PATH}` is invalid ({VALUE}).';
|
|
46
|
+
msg.String.minlength = 'Path `{PATH}` (`{VALUE}`, length {LENGTH}) is shorter than the minimum allowed length ({MINLENGTH}).';
|
|
47
|
+
msg.String.maxlength = 'Path `{PATH}` (`{VALUE}`, length {LENGTH}) is longer than the maximum allowed length ({MAXLENGTH}).';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Module dependencies.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const MongooseError = require('./mongooseError');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* MissingSchema Error constructor.
|
|
12
|
+
* @param {String} name
|
|
13
|
+
* @api private
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
class MissingSchemaError extends MongooseError {
|
|
17
|
+
|
|
18
|
+
constructor(name) {
|
|
19
|
+
const msg = 'Schema hasn\'t been registered for model "' + name + '".\n'
|
|
20
|
+
+ 'Use mongoose.model(name, schema)';
|
|
21
|
+
super(msg);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(MissingSchemaError.prototype, 'name', {
|
|
26
|
+
value: 'MissingSchemaError'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/*!
|
|
30
|
+
* exports
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
module.exports = MissingSchemaError;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* Module dependencies.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const MongooseError = require('./mongooseError');
|
|
8
|
+
const util = require('util');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* OverwriteModel Error constructor.
|
|
12
|
+
* @api private
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class DocumentNotFoundError extends MongooseError {
|
|
16
|
+
|
|
17
|
+
constructor(filter, model, numAffected, result) {
|
|
18
|
+
let msg;
|
|
19
|
+
const messages = MongooseError.messages;
|
|
20
|
+
if (messages.DocumentNotFoundError != null) {
|
|
21
|
+
msg = typeof messages.DocumentNotFoundError === 'function' ?
|
|
22
|
+
messages.DocumentNotFoundError(filter, model) :
|
|
23
|
+
messages.DocumentNotFoundError;
|
|
24
|
+
} else {
|
|
25
|
+
msg = 'No document found for query "' + util.inspect(filter) +
|
|
26
|
+
'" on model "' + model + '"';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
super(msg);
|
|
30
|
+
|
|
31
|
+
this.result = result;
|
|
32
|
+
this.numAffected = numAffected;
|
|
33
|
+
this.filter = filter;
|
|
34
|
+
// Backwards compat
|
|
35
|
+
this.query = filter;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Object.defineProperty(DocumentNotFoundError.prototype, 'name', {
|
|
40
|
+
value: 'DocumentNotFoundError'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/*!
|
|
44
|
+
* exports
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
module.exports = DocumentNotFoundError;
|