mongoose 7.0.1 → 7.0.2
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/.eslintrc.js +232 -0
- package/README.md +15 -15
- package/dist/browser.umd.js +1 -1
- package/lib/aggregate.js +1 -1
- package/lib/connection.js +10 -0
- package/lib/cursor/AggregationCursor.js +1 -1
- package/lib/cursor/QueryCursor.js +1 -1
- package/lib/document.js +24 -25
- package/lib/helpers/document/applyDefaults.js +1 -1
- package/lib/model.js +7 -8
- package/lib/query.js +3 -2
- package/lib/schema/documentarray.js +5 -3
- package/lib/schema.js +10 -3
- package/package.json +3 -1
- package/scripts/generateSearch.js +31 -24
- package/types/cursor.d.ts +2 -2
- package/types/query.d.ts +2 -2
- package/types/types.d.ts +1 -1
- package/.eslintrc.json +0 -195
package/lib/aggregate.js
CHANGED
|
@@ -1127,7 +1127,7 @@ Aggregate.prototype.catch = function(reject) {
|
|
|
1127
1127
|
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
|
|
1128
1128
|
* support async iterators.
|
|
1129
1129
|
*
|
|
1130
|
-
* @method Symbol.asyncIterator
|
|
1130
|
+
* @method [Symbol.asyncIterator]
|
|
1131
1131
|
* @memberOf Aggregate
|
|
1132
1132
|
* @instance
|
|
1133
1133
|
* @api public
|
package/lib/connection.js
CHANGED
|
@@ -1057,6 +1057,16 @@ Connection.prototype._close = async function _close(force, destroy) {
|
|
|
1057
1057
|
return this;
|
|
1058
1058
|
};
|
|
1059
1059
|
|
|
1060
|
+
/**
|
|
1061
|
+
* Abstract method that drivers must implement.
|
|
1062
|
+
*
|
|
1063
|
+
* @api private
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
1066
|
+
Connection.prototype.doClose = function() {
|
|
1067
|
+
throw new Error('Connection#doClose unimplemented by driver');
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1060
1070
|
/**
|
|
1061
1071
|
* Called when the connection closes
|
|
1062
1072
|
*
|
|
@@ -263,7 +263,7 @@ AggregationCursor.prototype.eachAsync = function(fn, opts, callback) {
|
|
|
263
263
|
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
|
|
264
264
|
* support async iterators.
|
|
265
265
|
*
|
|
266
|
-
* @method Symbol.asyncIterator
|
|
266
|
+
* @method [Symbol.asyncIterator]
|
|
267
267
|
* @memberOf AggregationCursor
|
|
268
268
|
* @instance
|
|
269
269
|
* @api public
|
|
@@ -347,7 +347,7 @@ QueryCursor.prototype._transformForAsyncIterator = function() {
|
|
|
347
347
|
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
|
|
348
348
|
* support async iterators.
|
|
349
349
|
*
|
|
350
|
-
* @method Symbol.asyncIterator
|
|
350
|
+
* @method [Symbol.asyncIterator]
|
|
351
351
|
* @memberOf QueryCursor
|
|
352
352
|
* @instance
|
|
353
353
|
* @api public
|
package/lib/document.js
CHANGED
|
@@ -2557,7 +2557,7 @@ function _evaluateRequiredFunctions(doc) {
|
|
|
2557
2557
|
* ignore
|
|
2558
2558
|
*/
|
|
2559
2559
|
|
|
2560
|
-
function _getPathsToValidate(doc) {
|
|
2560
|
+
function _getPathsToValidate(doc, pathsToValidate, pathsToSkip) {
|
|
2561
2561
|
const skipSchemaValidators = {};
|
|
2562
2562
|
|
|
2563
2563
|
_evaluateRequiredFunctions(doc);
|
|
@@ -2628,6 +2628,22 @@ function _getPathsToValidate(doc) {
|
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
2630
|
|
|
2631
|
+
for (const path of paths) {
|
|
2632
|
+
// Single nested paths (paths embedded under single nested subdocs) will
|
|
2633
|
+
// be validated on their own when we call `validate()` on the subdoc itself.
|
|
2634
|
+
// Re: gh-8468
|
|
2635
|
+
if (doc.$__schema.singleNestedPaths.hasOwnProperty(path)) {
|
|
2636
|
+
paths.delete(path);
|
|
2637
|
+
continue;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
if (Array.isArray(pathsToValidate)) {
|
|
2642
|
+
paths = _handlePathsToValidate(paths, pathsToValidate);
|
|
2643
|
+
} else if (Array.isArray(pathsToSkip)) {
|
|
2644
|
+
paths = _handlePathsToSkip(paths, pathsToSkip);
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2631
2647
|
// from here on we're not removing items from paths
|
|
2632
2648
|
|
|
2633
2649
|
// gh-661: if a whole array is modified, make sure to run validation on all
|
|
@@ -2687,13 +2703,6 @@ function _getPathsToValidate(doc) {
|
|
|
2687
2703
|
}
|
|
2688
2704
|
|
|
2689
2705
|
for (const path of paths) {
|
|
2690
|
-
// Single nested paths (paths embedded under single nested subdocs) will
|
|
2691
|
-
// be validated on their own when we call `validate()` on the subdoc itself.
|
|
2692
|
-
// Re: gh-8468
|
|
2693
|
-
if (doc.$__schema.singleNestedPaths.hasOwnProperty(path)) {
|
|
2694
|
-
paths.delete(path);
|
|
2695
|
-
continue;
|
|
2696
|
-
}
|
|
2697
2706
|
const _pathType = doc.$__schema.path(path);
|
|
2698
2707
|
if (!_pathType || !_pathType.$isSchemaMap) {
|
|
2699
2708
|
continue;
|
|
@@ -2776,7 +2785,7 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2776
2785
|
};
|
|
2777
2786
|
|
|
2778
2787
|
// only validate required fields when necessary
|
|
2779
|
-
const pathDetails = _getPathsToValidate(this);
|
|
2788
|
+
const pathDetails = _getPathsToValidate(this, pathsToValidate, pathsToSkip);
|
|
2780
2789
|
let paths = shouldValidateModifiedOnly ?
|
|
2781
2790
|
pathDetails[0].filter((path) => this.$isModified(path)) :
|
|
2782
2791
|
pathDetails[0];
|
|
@@ -2784,11 +2793,6 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2784
2793
|
if (typeof pathsToValidate === 'string') {
|
|
2785
2794
|
pathsToValidate = pathsToValidate.split(' ');
|
|
2786
2795
|
}
|
|
2787
|
-
if (Array.isArray(pathsToValidate)) {
|
|
2788
|
-
paths = _handlePathsToValidate(paths, pathsToValidate);
|
|
2789
|
-
} else if (pathsToSkip) {
|
|
2790
|
-
paths = _handlePathsToSkip(paths, pathsToSkip);
|
|
2791
|
-
}
|
|
2792
2796
|
|
|
2793
2797
|
if (paths.length === 0) {
|
|
2794
2798
|
return immediate(function() {
|
|
@@ -2907,12 +2911,12 @@ function _handlePathsToValidate(paths, pathsToValidate) {
|
|
|
2907
2911
|
}
|
|
2908
2912
|
}
|
|
2909
2913
|
|
|
2910
|
-
const ret =
|
|
2914
|
+
const ret = new Set();
|
|
2911
2915
|
for (const path of paths) {
|
|
2912
2916
|
if (_pathsToValidate.has(path)) {
|
|
2913
|
-
ret.
|
|
2917
|
+
ret.add(path);
|
|
2914
2918
|
} else if (parentPaths.has(path)) {
|
|
2915
|
-
ret.
|
|
2919
|
+
ret.add(parentPaths.get(path));
|
|
2916
2920
|
}
|
|
2917
2921
|
}
|
|
2918
2922
|
return ret;
|
|
@@ -2924,8 +2928,8 @@ function _handlePathsToValidate(paths, pathsToValidate) {
|
|
|
2924
2928
|
|
|
2925
2929
|
function _handlePathsToSkip(paths, pathsToSkip) {
|
|
2926
2930
|
pathsToSkip = new Set(pathsToSkip);
|
|
2927
|
-
paths = paths.filter(p => !pathsToSkip.has(p));
|
|
2928
|
-
return paths;
|
|
2931
|
+
paths = Array.from(paths).filter(p => !pathsToSkip.has(p));
|
|
2932
|
+
return new Set(paths);
|
|
2929
2933
|
}
|
|
2930
2934
|
|
|
2931
2935
|
/**
|
|
@@ -2981,17 +2985,12 @@ Document.prototype.validateSync = function(pathsToValidate, options) {
|
|
|
2981
2985
|
}
|
|
2982
2986
|
|
|
2983
2987
|
// only validate required fields when necessary
|
|
2984
|
-
const pathDetails = _getPathsToValidate(this);
|
|
2988
|
+
const pathDetails = _getPathsToValidate(this, pathsToValidate, pathsToSkip);
|
|
2985
2989
|
let paths = shouldValidateModifiedOnly ?
|
|
2986
2990
|
pathDetails[0].filter((path) => this.$isModified(path)) :
|
|
2987
2991
|
pathDetails[0];
|
|
2988
2992
|
const skipSchemaValidators = pathDetails[1];
|
|
2989
2993
|
|
|
2990
|
-
if (Array.isArray(pathsToValidate)) {
|
|
2991
|
-
paths = _handlePathsToValidate(paths, pathsToValidate);
|
|
2992
|
-
} else if (Array.isArray(pathsToSkip)) {
|
|
2993
|
-
paths = _handlePathsToSkip(paths, pathsToSkip);
|
|
2994
|
-
}
|
|
2995
2994
|
const validating = {};
|
|
2996
2995
|
|
|
2997
2996
|
for (let i = 0, len = paths.length; i < len; ++i) {
|
|
@@ -32,7 +32,7 @@ module.exports = function applyDefaults(doc, fields, exclude, hasIncludedChildre
|
|
|
32
32
|
}
|
|
33
33
|
} else if (exclude === false && fields && !included) {
|
|
34
34
|
const hasSubpaths = type.$isSingleNested || type.$isMongooseDocumentArray;
|
|
35
|
-
if (curPath in fields || (hasSubpaths && hasIncludedChildren != null && hasIncludedChildren[curPath])) {
|
|
35
|
+
if (curPath in fields || (j === len - 1 && hasSubpaths && hasIncludedChildren != null && hasIncludedChildren[curPath])) {
|
|
36
36
|
included = true;
|
|
37
37
|
} else if (hasIncludedChildren != null && !hasIncludedChildren[curPath]) {
|
|
38
38
|
break;
|
package/lib/model.js
CHANGED
|
@@ -1252,9 +1252,11 @@ for (const i in EventEmitter.prototype) {
|
|
|
1252
1252
|
* Mongoose calls this function automatically when a model is created using
|
|
1253
1253
|
* [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or
|
|
1254
1254
|
* [`connection.model()`](/docs/api/connection.html#connection_Connection-model), so you
|
|
1255
|
-
* don't need to call
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1255
|
+
* don't need to call `init()` to trigger index builds.
|
|
1256
|
+
*
|
|
1257
|
+
* However, you _may_ need to call `init()` to get back a promise that will resolve when your indexes are finished.
|
|
1258
|
+
* Calling `await Model.init()` is helpful if you need to wait for indexes to build before continuing.
|
|
1259
|
+
* For example, if you want to wait for unique indexes to build before continuing with a test case.
|
|
1258
1260
|
*
|
|
1259
1261
|
* #### Example:
|
|
1260
1262
|
*
|
|
@@ -1263,11 +1265,8 @@ for (const i in EventEmitter.prototype) {
|
|
|
1263
1265
|
* // `Event.init()` on your own.
|
|
1264
1266
|
* const Event = mongoose.model('Event', eventSchema);
|
|
1265
1267
|
*
|
|
1266
|
-
* Event.init()
|
|
1267
|
-
*
|
|
1268
|
-
* // over promises.
|
|
1269
|
-
* console.log('Indexes are done building!');
|
|
1270
|
-
* });
|
|
1268
|
+
* await Event.init();
|
|
1269
|
+
* console.log('Indexes are done building!');
|
|
1271
1270
|
*
|
|
1272
1271
|
* @api public
|
|
1273
1272
|
* @returns {Promise}
|
package/lib/query.js
CHANGED
|
@@ -4482,7 +4482,8 @@ Query.prototype.finally = function(onFinally) {
|
|
|
4482
4482
|
*
|
|
4483
4483
|
* @return {String}
|
|
4484
4484
|
* @api public
|
|
4485
|
-
* @method toStringTag
|
|
4485
|
+
* @method [Symbol.toStringTag]
|
|
4486
|
+
* @memberOf Query
|
|
4486
4487
|
*/
|
|
4487
4488
|
|
|
4488
4489
|
Query.prototype[Symbol.toStringTag] = function toString() {
|
|
@@ -5192,7 +5193,7 @@ Query.prototype.nearSphere = function() {
|
|
|
5192
5193
|
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
|
|
5193
5194
|
* support async iterators.
|
|
5194
5195
|
*
|
|
5195
|
-
* @method Symbol.asyncIterator
|
|
5196
|
+
* @method [Symbol.asyncIterator]
|
|
5196
5197
|
* @memberOf Query
|
|
5197
5198
|
* @instance
|
|
5198
5199
|
* @api public
|
|
@@ -416,6 +416,8 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
416
416
|
|
|
417
417
|
options = options || {};
|
|
418
418
|
|
|
419
|
+
const path = options.path || this.path;
|
|
420
|
+
|
|
419
421
|
if (!Array.isArray(value)) {
|
|
420
422
|
if (!init && !DocumentArrayPath.options.castNonArrays) {
|
|
421
423
|
throw new CastError('DocumentArray', value, this.path, null, this);
|
|
@@ -423,7 +425,7 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
423
425
|
// gh-2442 mark whole array as modified if we're initializing a doc from
|
|
424
426
|
// the db and the path isn't an array in the document
|
|
425
427
|
if (!!doc && init) {
|
|
426
|
-
doc.markModified(
|
|
428
|
+
doc.markModified(path);
|
|
427
429
|
}
|
|
428
430
|
return this.cast([value], doc, init, prev, options);
|
|
429
431
|
}
|
|
@@ -431,7 +433,7 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
431
433
|
// We need to create a new array, otherwise change tracking will
|
|
432
434
|
// update the old doc (gh-4449)
|
|
433
435
|
if (!options.skipDocumentArrayCast || utils.isMongooseDocumentArray(value)) {
|
|
434
|
-
value = new MongooseDocumentArray(value,
|
|
436
|
+
value = new MongooseDocumentArray(value, path, doc);
|
|
435
437
|
}
|
|
436
438
|
|
|
437
439
|
if (prev != null) {
|
|
@@ -439,7 +441,7 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
439
441
|
}
|
|
440
442
|
|
|
441
443
|
if (options.arrayPathIndex != null) {
|
|
442
|
-
value[arrayPathSymbol] =
|
|
444
|
+
value[arrayPathSymbol] = path + '.' + options.arrayPathIndex;
|
|
443
445
|
}
|
|
444
446
|
|
|
445
447
|
const rawArray = utils.isMongooseDocumentArray(value) ? value.__array : value;
|
package/lib/schema.js
CHANGED
|
@@ -734,8 +734,15 @@ Schema.prototype.add = function add(obj, prefix) {
|
|
|
734
734
|
if (prefix) {
|
|
735
735
|
this.nested[prefix.substring(0, prefix.length - 1)] = true;
|
|
736
736
|
}
|
|
737
|
-
|
|
738
|
-
const
|
|
737
|
+
|
|
738
|
+
const childSchemaOptions = {};
|
|
739
|
+
if (this._userProvidedOptions.typeKey) {
|
|
740
|
+
childSchemaOptions.typeKey = this._userProvidedOptions.typeKey;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const _schema = new Schema(_typeDef, childSchemaOptions);
|
|
744
|
+
_schema.$implicitlyCreated = true;
|
|
745
|
+
const schemaWrappedPath = Object.assign({}, val, { [typeKey]: _schema });
|
|
739
746
|
this.path(prefix + key, schemaWrappedPath);
|
|
740
747
|
} else {
|
|
741
748
|
// Either the type is non-POJO or we interpret it as Mixed anyway
|
|
@@ -1322,6 +1329,7 @@ Schema.prototype.interpretAsType = function(path, obj, options) {
|
|
|
1322
1329
|
} else if (Schema.Types.DocumentArray.defaultOptions._id != null) {
|
|
1323
1330
|
childSchemaOptions._id = Schema.Types.DocumentArray.defaultOptions._id;
|
|
1324
1331
|
}
|
|
1332
|
+
|
|
1325
1333
|
const childSchema = new Schema(castFromTypeKey, childSchemaOptions);
|
|
1326
1334
|
childSchema.$implicitlyCreated = true;
|
|
1327
1335
|
return new MongooseTypes.DocumentArray(path, childSchema, obj);
|
|
@@ -1365,7 +1373,6 @@ Schema.prototype.interpretAsType = function(path, obj, options) {
|
|
|
1365
1373
|
}
|
|
1366
1374
|
|
|
1367
1375
|
if (type && type.instanceOfSchema) {
|
|
1368
|
-
|
|
1369
1376
|
return new MongooseTypes.Subdocument(type, path, obj);
|
|
1370
1377
|
}
|
|
1371
1378
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.2",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dotenv": "16.0.3",
|
|
47
47
|
"dox": "1.0.0",
|
|
48
48
|
"eslint": "8.35.0",
|
|
49
|
+
"eslint-plugin-markdown": "^3.0.0",
|
|
49
50
|
"eslint-plugin-mocha-no-only": "1.1.1",
|
|
50
51
|
"express": "^4.18.1",
|
|
51
52
|
"highlight.js": "11.7.0",
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
"lint": "eslint .",
|
|
96
97
|
"lint-js": "eslint . --ext .js",
|
|
97
98
|
"lint-ts": "eslint . --ext .ts",
|
|
99
|
+
"lint-md": "eslint . --ext .md",
|
|
98
100
|
"build-browser": "(rm ./dist/* || true) && node ./scripts/build-browser.js",
|
|
99
101
|
"prepublishOnly": "npm run build-browser",
|
|
100
102
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let config;
|
|
4
|
+
try {
|
|
5
|
+
config = require('../.config.js');
|
|
6
|
+
} finally {
|
|
7
|
+
if (!config || !config.uri) {
|
|
8
|
+
console.error('No Config or config.URI given, please create a .config.js file with those values in the root of the repository');
|
|
9
|
+
process.exit(-1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
const cheerio = require('cheerio');
|
|
5
13
|
const filemap = require('../docs/source');
|
|
6
14
|
const fs = require('fs');
|
|
@@ -30,25 +38,27 @@ const Content = mongoose.model('Content', contentSchema, 'Content');
|
|
|
30
38
|
|
|
31
39
|
const contents = [];
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
contents.push(content);
|
|
49
|
-
}
|
|
41
|
+
const api = require('../docs/source/api');
|
|
42
|
+
|
|
43
|
+
// API docs are special, because they are not added to the file-map individually currently and use different properties
|
|
44
|
+
for (const _class of api.docs) {
|
|
45
|
+
for (const prop of _class.props) {
|
|
46
|
+
const content = new Content({
|
|
47
|
+
title: `API: ${prop.name}`,
|
|
48
|
+
body: prop.description,
|
|
49
|
+
url: `api/${_class.fileName}.html#${prop.anchorId}`
|
|
50
|
+
});
|
|
51
|
+
const err = content.validateSync();
|
|
52
|
+
if (err != null) {
|
|
53
|
+
console.error(content);
|
|
54
|
+
throw err;
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
contents.push(content);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const [filename, file] of Object.entries(filemap)) {
|
|
61
|
+
if (file.markdown) {
|
|
52
62
|
let text = fs.readFileSync(filename, 'utf8');
|
|
53
63
|
text = markdown.parse(text);
|
|
54
64
|
|
|
@@ -120,11 +130,6 @@ run().catch(async error => {
|
|
|
120
130
|
});
|
|
121
131
|
|
|
122
132
|
async function run() {
|
|
123
|
-
if (!config || !config.uri) {
|
|
124
|
-
console.error('No Config or config.URI given, please create a .config.js file with those values');
|
|
125
|
-
process.exit(-1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
133
|
await mongoose.connect(config.uri, { dbName: 'mongoose', serverSelectionTimeoutMS: 5000 });
|
|
129
134
|
|
|
130
135
|
// wait for the index to be created
|
|
@@ -152,5 +157,7 @@ async function run() {
|
|
|
152
157
|
|
|
153
158
|
console.log(results.map(res => res.url));
|
|
154
159
|
|
|
160
|
+
console.log(`Added ${contents.length} Content`);
|
|
161
|
+
|
|
155
162
|
process.exit(0);
|
|
156
163
|
}
|
package/types/cursor.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ declare module 'mongoose' {
|
|
|
38
38
|
* will wait for the promise to resolve before iterating on to the next one.
|
|
39
39
|
* Returns a promise that resolves when done.
|
|
40
40
|
*/
|
|
41
|
-
eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
|
|
42
|
-
eachAsync(fn: (doc: DocType) => any, options?: EachAsyncOptions): Promise<void>;
|
|
41
|
+
eachAsync(fn: (doc: DocType[], i: number) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
|
|
42
|
+
eachAsync(fn: (doc: DocType, i: number) => any, options?: EachAsyncOptions): Promise<void>;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Registers a transform function which subsequently maps documents retrieved
|
package/types/query.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ declare module 'mongoose' {
|
|
|
109
109
|
/**
|
|
110
110
|
* If truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document.
|
|
111
111
|
*/
|
|
112
|
-
lean?: boolean | any
|
|
112
|
+
lean?: boolean | Record<string, any>;
|
|
113
113
|
limit?: number;
|
|
114
114
|
maxTimeMS?: number;
|
|
115
115
|
multi?: boolean;
|
|
@@ -532,7 +532,7 @@ declare module 'mongoose' {
|
|
|
532
532
|
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions<DocType> | null): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
533
533
|
|
|
534
534
|
/** Specifies which document fields to include or exclude (also known as the query "projection") */
|
|
535
|
-
select(arg: string |
|
|
535
|
+
select(arg: string | string[] | Record<string, number | boolean | object>): this;
|
|
536
536
|
|
|
537
537
|
/** Determines if field selection has been made. */
|
|
538
538
|
selected(): boolean;
|
package/types/types.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ declare module 'mongoose' {
|
|
|
61
61
|
|
|
62
62
|
class DocumentArray<T> extends Types.Array<T extends Types.Subdocument ? T : Types.Subdocument<InferId<T>> & T> {
|
|
63
63
|
/** DocumentArray constructor */
|
|
64
|
-
constructor(values:
|
|
64
|
+
constructor(values: (AnyKeys<T> & AnyObject)[]);
|
|
65
65
|
|
|
66
66
|
isMongooseDocumentArray: true;
|
|
67
67
|
|
package/.eslintrc.json
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"eslint:recommended"
|
|
4
|
-
],
|
|
5
|
-
"ignorePatterns": [
|
|
6
|
-
"docs",
|
|
7
|
-
"tools",
|
|
8
|
-
"dist",
|
|
9
|
-
"website.js",
|
|
10
|
-
"test/files/*",
|
|
11
|
-
"benchmarks"
|
|
12
|
-
],
|
|
13
|
-
"overrides": [
|
|
14
|
-
{
|
|
15
|
-
"files": [
|
|
16
|
-
"**/*.{ts,tsx}"
|
|
17
|
-
],
|
|
18
|
-
"extends": [
|
|
19
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
20
|
-
"plugin:@typescript-eslint/recommended"
|
|
21
|
-
],
|
|
22
|
-
"plugins": [
|
|
23
|
-
"@typescript-eslint"
|
|
24
|
-
],
|
|
25
|
-
"rules": {
|
|
26
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
27
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
28
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
29
|
-
"spaced-comment": [
|
|
30
|
-
"error",
|
|
31
|
-
"always",
|
|
32
|
-
{
|
|
33
|
-
"block": {
|
|
34
|
-
"markers": [
|
|
35
|
-
"!"
|
|
36
|
-
],
|
|
37
|
-
"balanced": true
|
|
38
|
-
},
|
|
39
|
-
"markers": [
|
|
40
|
-
"/"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
45
|
-
"@typescript-eslint/ban-types": "off",
|
|
46
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
47
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
48
|
-
"@typescript-eslint/indent": [
|
|
49
|
-
"warn",
|
|
50
|
-
2,
|
|
51
|
-
{
|
|
52
|
-
"SwitchCase": 1,
|
|
53
|
-
"ignoredNodes": ["TSTypeParameterInstantiation"]
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"@typescript-eslint/prefer-optional-chain": "error",
|
|
57
|
-
"@typescript-eslint/brace-style": "error",
|
|
58
|
-
"@typescript-eslint/no-dupe-class-members": "error",
|
|
59
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
60
|
-
"@typescript-eslint/type-annotation-spacing": "error",
|
|
61
|
-
"@typescript-eslint/object-curly-spacing": [
|
|
62
|
-
"error",
|
|
63
|
-
"always"
|
|
64
|
-
],
|
|
65
|
-
"@typescript-eslint/semi": "error",
|
|
66
|
-
"@typescript-eslint/space-before-function-paren": [
|
|
67
|
-
"error",
|
|
68
|
-
"never"
|
|
69
|
-
],
|
|
70
|
-
"@typescript-eslint/space-infix-ops": "off"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
"plugins": [
|
|
75
|
-
"mocha-no-only"
|
|
76
|
-
],
|
|
77
|
-
"parserOptions": {
|
|
78
|
-
"ecmaVersion": 2020
|
|
79
|
-
},
|
|
80
|
-
"env": {
|
|
81
|
-
"node": true,
|
|
82
|
-
"es6": true
|
|
83
|
-
},
|
|
84
|
-
"rules": {
|
|
85
|
-
"comma-style": "error",
|
|
86
|
-
"indent": [
|
|
87
|
-
"error",
|
|
88
|
-
2,
|
|
89
|
-
{
|
|
90
|
-
"SwitchCase": 1,
|
|
91
|
-
"VariableDeclarator": 2
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
"keyword-spacing": "error",
|
|
95
|
-
"no-whitespace-before-property": "error",
|
|
96
|
-
"no-buffer-constructor": "warn",
|
|
97
|
-
"no-console": "off",
|
|
98
|
-
"no-constant-condition": "off",
|
|
99
|
-
"no-multi-spaces": "error",
|
|
100
|
-
"func-call-spacing": "error",
|
|
101
|
-
"no-trailing-spaces": "error",
|
|
102
|
-
"no-undef": "error",
|
|
103
|
-
"no-unneeded-ternary": "error",
|
|
104
|
-
"no-const-assign": "error",
|
|
105
|
-
"no-useless-rename": "error",
|
|
106
|
-
"no-dupe-keys": "error",
|
|
107
|
-
"space-in-parens": [
|
|
108
|
-
"error",
|
|
109
|
-
"never"
|
|
110
|
-
],
|
|
111
|
-
"spaced-comment": [
|
|
112
|
-
"error",
|
|
113
|
-
"always",
|
|
114
|
-
{
|
|
115
|
-
"block": {
|
|
116
|
-
"markers": [
|
|
117
|
-
"!"
|
|
118
|
-
],
|
|
119
|
-
"balanced": true
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
],
|
|
123
|
-
"key-spacing": [
|
|
124
|
-
"error",
|
|
125
|
-
{
|
|
126
|
-
"beforeColon": false,
|
|
127
|
-
"afterColon": true
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"comma-spacing": [
|
|
131
|
-
"error",
|
|
132
|
-
{
|
|
133
|
-
"before": false,
|
|
134
|
-
"after": true
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
"array-bracket-spacing": 1,
|
|
138
|
-
"arrow-spacing": [
|
|
139
|
-
"error",
|
|
140
|
-
{
|
|
141
|
-
"before": true,
|
|
142
|
-
"after": true
|
|
143
|
-
}
|
|
144
|
-
],
|
|
145
|
-
"object-curly-spacing": [
|
|
146
|
-
"error",
|
|
147
|
-
"always"
|
|
148
|
-
],
|
|
149
|
-
"comma-dangle": [
|
|
150
|
-
"error",
|
|
151
|
-
"never"
|
|
152
|
-
],
|
|
153
|
-
"no-unreachable": "error",
|
|
154
|
-
"quotes": [
|
|
155
|
-
"error",
|
|
156
|
-
"single"
|
|
157
|
-
],
|
|
158
|
-
"quote-props": [
|
|
159
|
-
"error",
|
|
160
|
-
"as-needed"
|
|
161
|
-
],
|
|
162
|
-
"semi": "error",
|
|
163
|
-
"no-extra-semi": "error",
|
|
164
|
-
"semi-spacing": "error",
|
|
165
|
-
"no-spaced-func": "error",
|
|
166
|
-
"no-throw-literal": "error",
|
|
167
|
-
"space-before-blocks": "error",
|
|
168
|
-
"space-before-function-paren": [
|
|
169
|
-
"error",
|
|
170
|
-
"never"
|
|
171
|
-
],
|
|
172
|
-
"space-infix-ops": "error",
|
|
173
|
-
"space-unary-ops": "error",
|
|
174
|
-
"no-var": "warn",
|
|
175
|
-
"prefer-const": "warn",
|
|
176
|
-
"strict": [
|
|
177
|
-
"error",
|
|
178
|
-
"global"
|
|
179
|
-
],
|
|
180
|
-
"no-restricted-globals": [
|
|
181
|
-
"error",
|
|
182
|
-
{
|
|
183
|
-
"name": "context",
|
|
184
|
-
"message": "Don't use Mocha's global context"
|
|
185
|
-
}
|
|
186
|
-
],
|
|
187
|
-
"no-prototype-builtins": "off",
|
|
188
|
-
"mocha-no-only/mocha-no-only": [
|
|
189
|
-
"error"
|
|
190
|
-
],
|
|
191
|
-
"no-empty": "off",
|
|
192
|
-
"eol-last": "warn",
|
|
193
|
-
"no-multiple-empty-lines": ["warn", { "max": 2 }]
|
|
194
|
-
}
|
|
195
|
-
}
|