@datanimbus/mongoose 6.13.10 → 9.13.1
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/dist/browser.umd.js +1 -1
- package/lib/cast.js +13 -4
- package/lib/cursor/QueryCursor.js +8 -1
- package/lib/document.js +21 -4
- package/lib/helpers/discriminator/getConstructor.js +4 -2
- package/lib/helpers/discriminator/getDiscriminatorByKey.js +17 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -1
- package/lib/helpers/isBsonType.js +3 -1
- package/lib/helpers/path/setDottedPath.js +5 -0
- package/lib/helpers/populate/getModelsMapForPopulate.js +2 -1
- package/lib/helpers/query/sanitizeFilter.js +5 -2
- package/lib/helpers/query/sanitizeProjection.js +18 -1
- package/lib/helpers/query/trusted.js +1 -1
- package/lib/helpers/query/wrapThunk.js +6 -1
- package/lib/helpers/update/castArrayFilters.js +2 -1
- package/lib/model.js +3 -2
- package/lib/query.js +74 -26
- package/lib/queryhelpers.js +23 -1
- package/lib/schema/array.js +11 -7
- package/lib/schema.js +16 -7
- package/lib/types/DocumentArray/methods/index.js +11 -6
- package/lib/utils.js +6 -0
- package/package.json +2 -8
- package/scripts/tsc-diagnostics-check.js +1 -1
- package/types/expressions.d.ts +102 -0
- package/types/query.d.ts +9 -1
package/lib/schema/array.js
CHANGED
|
@@ -18,6 +18,7 @@ const util = require('util');
|
|
|
18
18
|
const utils = require('../utils');
|
|
19
19
|
const castToNumber = require('./operators/helpers').castToNumber;
|
|
20
20
|
const geospatial = require('./operators/geospatial');
|
|
21
|
+
const getDiscriminatorByKey = require('../helpers/discriminator/getDiscriminatorByKey');
|
|
21
22
|
const getDiscriminatorByValue = require('../helpers/discriminator/getDiscriminatorByValue');
|
|
22
23
|
|
|
23
24
|
let MongooseArray;
|
|
@@ -506,9 +507,11 @@ SchemaArray.prototype.castForQuery = function($conditional, value) {
|
|
|
506
507
|
Constructor.schema &&
|
|
507
508
|
Constructor.schema.options &&
|
|
508
509
|
Constructor.schema.options.discriminatorKey) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
const discriminator = typeof val[Constructor.schema.options.discriminatorKey] === 'string' ?
|
|
511
|
+
getDiscriminatorByKey(Constructor.discriminators, val[Constructor.schema.options.discriminatorKey]) :
|
|
512
|
+
null;
|
|
513
|
+
if (discriminator) {
|
|
514
|
+
Constructor = discriminator;
|
|
512
515
|
} else {
|
|
513
516
|
const constructorByValue = getDiscriminatorByValue(Constructor.discriminators, val[Constructor.schema.options.discriminatorKey]);
|
|
514
517
|
if (constructorByValue) {
|
|
@@ -595,10 +598,11 @@ function cast$elemMatch(val) {
|
|
|
595
598
|
this.casterConstructor &&
|
|
596
599
|
this.casterConstructor.schema &&
|
|
597
600
|
this.casterConstructor.schema.discriminators || {};
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
601
|
+
const discriminator = discriminatorKey != null && val[discriminatorKey] != null ?
|
|
602
|
+
getDiscriminatorByKey(discriminators, val[discriminatorKey]) :
|
|
603
|
+
null;
|
|
604
|
+
if (discriminator != null) {
|
|
605
|
+
return cast(discriminator, val, null, this && this.$$context);
|
|
602
606
|
}
|
|
603
607
|
|
|
604
608
|
return cast(this.casterConstructor.schema, val, null, this && this.$$context);
|
package/lib/schema.js
CHANGED
|
@@ -955,7 +955,7 @@ reserved.collection = 1;
|
|
|
955
955
|
|
|
956
956
|
Schema.prototype.path = function(path, obj) {
|
|
957
957
|
if (obj === undefined) {
|
|
958
|
-
if (this.paths
|
|
958
|
+
if (Object.prototype.hasOwnProperty.call(this.paths, path)) {
|
|
959
959
|
return this.paths[path];
|
|
960
960
|
}
|
|
961
961
|
// Convert to '.$' to check subpaths re: gh-6405
|
|
@@ -983,9 +983,15 @@ Schema.prototype.path = function(path, obj) {
|
|
|
983
983
|
: undefined;
|
|
984
984
|
}
|
|
985
985
|
|
|
986
|
+
const subpaths = path.indexOf('.') === -1 ? [path] : path.split('.');
|
|
987
|
+
const last = subpaths.pop();
|
|
988
|
+
if (utils.specialProperties.has(last)) {
|
|
989
|
+
throw new Error('Cannot set special property `' + last + '` on a schema');
|
|
990
|
+
}
|
|
991
|
+
|
|
986
992
|
// some path names conflict with document methods
|
|
987
|
-
const firstPieceOfPath =
|
|
988
|
-
if (reserved
|
|
993
|
+
const firstPieceOfPath = subpaths.length === 0 ? last : subpaths[0];
|
|
994
|
+
if (Object.prototype.hasOwnProperty.call(reserved, firstPieceOfPath) && !this.options.supressReservedKeysWarning) {
|
|
989
995
|
const errorMessage = `\`${firstPieceOfPath}\` is a reserved schema pathname and may break some functionality. ` +
|
|
990
996
|
'You are allowed to use it, but use at your own risk. ' +
|
|
991
997
|
'To disable this warning pass `supressReservedKeysWarning` as a schema option.';
|
|
@@ -998,8 +1004,6 @@ Schema.prototype.path = function(path, obj) {
|
|
|
998
1004
|
}
|
|
999
1005
|
|
|
1000
1006
|
// update the tree
|
|
1001
|
-
const subpaths = path.split(/\./);
|
|
1002
|
-
const last = subpaths.pop();
|
|
1003
1007
|
let branch = this.tree;
|
|
1004
1008
|
let fullPath = '';
|
|
1005
1009
|
|
|
@@ -2138,6 +2142,12 @@ Schema.prototype.virtual = function(name, options) {
|
|
|
2138
2142
|
if (name instanceof VirtualType || getConstructorName(name) === 'VirtualType') {
|
|
2139
2143
|
return this.virtual(name.path, name.options);
|
|
2140
2144
|
}
|
|
2145
|
+
const parts = name.split('.');
|
|
2146
|
+
for (const part of parts) {
|
|
2147
|
+
if (utils.specialProperties.has(part)) {
|
|
2148
|
+
throw new MongooseError('Cannot set special property `' + part + '` on a schema');
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2141
2151
|
options = new VirtualOptions(options);
|
|
2142
2152
|
|
|
2143
2153
|
if (utils.hasUserDefinedProperty(options, ['ref', 'refPath'])) {
|
|
@@ -2220,7 +2230,6 @@ Schema.prototype.virtual = function(name, options) {
|
|
|
2220
2230
|
}
|
|
2221
2231
|
|
|
2222
2232
|
const virtuals = this.virtuals;
|
|
2223
|
-
const parts = name.split('.');
|
|
2224
2233
|
|
|
2225
2234
|
if (this.pathType(name) === 'real') {
|
|
2226
2235
|
throw new Error('Virtual path "' + name + '"' +
|
|
@@ -2589,7 +2598,7 @@ Schema.prototype._getPathType = function(path) {
|
|
|
2589
2598
|
};
|
|
2590
2599
|
}
|
|
2591
2600
|
return { schema: foundschema, pathType: 'real' };
|
|
2592
|
-
} else if (p === parts.length && schema.nested
|
|
2601
|
+
} else if (p === parts.length && Object.prototype.hasOwnProperty.call(schema.nested, trypath)) {
|
|
2593
2602
|
return { schema: schema, pathType: 'nested' };
|
|
2594
2603
|
}
|
|
2595
2604
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const ArrayMethods = require('../../array/methods');
|
|
4
4
|
const Document = require('../../../document');
|
|
5
5
|
const castObjectId = require('../../../cast/objectid');
|
|
6
|
+
const getDiscriminatorByKey = require('../../../helpers/discriminator/getDiscriminatorByKey');
|
|
6
7
|
const getDiscriminatorByValue = require('../../../helpers/discriminator/getDiscriminatorByValue');
|
|
7
8
|
const internalToObjectOptions = require('../../../options').internalToObjectOptions;
|
|
8
9
|
const utils = require('../../../utils');
|
|
@@ -75,9 +76,11 @@ const methods = {
|
|
|
75
76
|
Constructor.schema &&
|
|
76
77
|
Constructor.schema.options &&
|
|
77
78
|
Constructor.schema.options.discriminatorKey) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const discriminator = typeof value[Constructor.schema.options.discriminatorKey] === 'string' ?
|
|
80
|
+
getDiscriminatorByKey(Constructor.discriminators, value[Constructor.schema.options.discriminatorKey]) :
|
|
81
|
+
null;
|
|
82
|
+
if (discriminator) {
|
|
83
|
+
Constructor = discriminator;
|
|
81
84
|
} else {
|
|
82
85
|
const constructorByValue = getDiscriminatorByValue(Constructor.discriminators, value[Constructor.schema.options.discriminatorKey]);
|
|
83
86
|
if (constructorByValue) {
|
|
@@ -268,9 +271,11 @@ const methods = {
|
|
|
268
271
|
Constructor.schema &&
|
|
269
272
|
Constructor.schema.options &&
|
|
270
273
|
Constructor.schema.options.discriminatorKey) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
+
const discriminator = typeof obj[Constructor.schema.options.discriminatorKey] === 'string' ?
|
|
275
|
+
getDiscriminatorByKey(Constructor.discriminators, obj[Constructor.schema.options.discriminatorKey]) :
|
|
276
|
+
null;
|
|
277
|
+
if (discriminator) {
|
|
278
|
+
Constructor = discriminator;
|
|
274
279
|
} else {
|
|
275
280
|
const constructorByValue = getDiscriminatorByValue(Constructor.discriminators, obj[Constructor.schema.options.discriminatorKey]);
|
|
276
281
|
if (constructorByValue) {
|
package/lib/utils.js
CHANGED
|
@@ -905,6 +905,12 @@ exports.mergeClone = function(to, fromObj) {
|
|
|
905
905
|
if (specialProperties.has(key)) {
|
|
906
906
|
continue;
|
|
907
907
|
}
|
|
908
|
+
// Skip inherited properties like `Object.prototype.toString` to avoid setting
|
|
909
|
+
// properties on shared objects. Document properties are getters on the
|
|
910
|
+
// prototype, so check `_doc`.
|
|
911
|
+
if (!exports.object.hasOwnProperty(to.$__ == null ? to : to._doc, key) && key in to) {
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
908
914
|
if (typeof to[key] === 'undefined') {
|
|
909
915
|
to[key] = exports.clone(fromObj[key], {
|
|
910
916
|
transform: false,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datanimbus/mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.13.1",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"kareem": "2.5.1",
|
|
24
24
|
"mongodb": "4.17.2",
|
|
25
25
|
"mpath": "0.9.0",
|
|
26
|
-
"mquery": "4.0.
|
|
26
|
+
"mquery": "4.0.4",
|
|
27
27
|
"ms": "2.1.3",
|
|
28
28
|
"sift": "16.0.1"
|
|
29
29
|
},
|
|
@@ -78,25 +78,20 @@
|
|
|
78
78
|
"scripts": {
|
|
79
79
|
"docs:clean": "npm run docs:clean:stable",
|
|
80
80
|
"docs:clean:stable": "rimraf index.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/api && rimraf -rf ./docs/tutorials/*.html && rimraf -rf ./docs/typescript/*.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
|
|
81
|
-
"docs:clean:5x": "rimraf index.html && rimraf -rf ./docs/5.x && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
|
|
82
81
|
"docs:clean:6x": "rimraf index.html && rimraf -rf ./docs/6.x && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
|
|
83
82
|
"docs:copy:tmp": "mkdirp ./tmp/docs/css && mkdirp ./tmp/docs/js && mkdirp ./tmp/docs/images && mkdirp ./tmp/docs/tutorials && mkdirp ./tmp/docs/typescript && mkdirp ./tmp/docs/api && ncp ./docs/css ./tmp/docs/css --filter=.css$ && ncp ./docs/js ./tmp/docs/js --filter=.js$ && ncp ./docs/images ./tmp/docs/images && ncp ./docs/tutorials ./tmp/docs/tutorials && ncp ./docs/typescript ./tmp/docs/typescript && ncp ./docs/api ./tmp/docs/api && cp index.html ./tmp && cp docs/*.html ./tmp/docs/",
|
|
84
|
-
"docs:copy:tmp:5x": "rimraf ./docs/5.x && ncp ./tmp ./docs/5.x",
|
|
85
83
|
"docs:move:6x:tmp": "mv ./docs/6.x ./tmp",
|
|
86
84
|
"docs:copy:tmp:6x": "rimraf ./docs/6.x && ncp ./tmp ./docs/6.x",
|
|
87
85
|
"docs:checkout:gh-pages": "git checkout gh-pages",
|
|
88
|
-
"docs:checkout:5x": "git checkout 5.x",
|
|
89
86
|
"docs:checkout:6x": "git checkout 6.x",
|
|
90
87
|
"docs:generate": "node ./scripts/website.js",
|
|
91
88
|
"docs:generate:search": "node ./scripts/generateSearch.js",
|
|
92
89
|
"docs:generate:sponsorData": "node ./scripts/loadSponsorData.js",
|
|
93
90
|
"docs:merge:stable": "git merge master",
|
|
94
|
-
"docs:merge:5x": "git merge 5.x",
|
|
95
91
|
"docs:merge:6x": "git merge 6.x",
|
|
96
92
|
"docs:test": "npm run docs:generate && npm run docs:generate:search",
|
|
97
93
|
"docs:view": "node ./scripts/static.js",
|
|
98
94
|
"docs:prepare:publish:stable": "npm run docs:checkout:gh-pages && npm run docs:merge:stable && npm run docs:clean:stable && npm run docs:generate && npm run docs:generate:search",
|
|
99
|
-
"docs:prepare:publish:5x": "npm run docs:checkout:5x && npm run docs:merge:5x && npm run docs:clean:stable && npm run docs:generate && npm run docs:copy:tmp && npm run docs:checkout:gh-pages && npm run docs:copy:tmp:5x",
|
|
100
95
|
"docs:prepare:publish:6x": "npm run docs:checkout:6x && npm run docs:merge:6x && npm run docs:clean:stable && env DOCS_DEPLOY=true npm run docs:generate && npm run docs:move:6x:tmp && npm run docs:checkout:gh-pages && npm run docs:copy:tmp:6x",
|
|
101
96
|
"docs:check-links": "blc http://127.0.0.1:8089 -ro",
|
|
102
97
|
"lint": "eslint .",
|
|
@@ -106,7 +101,6 @@
|
|
|
106
101
|
"build-browser": "(rm ./dist/* || true) && node ./scripts/build-browser.js",
|
|
107
102
|
"prepublishOnly": "npm run build-browser",
|
|
108
103
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
109
|
-
"release-5x": "git pull origin 5.x && git push origin 5.x && git push origin 5.x --tags && npm publish --tag 5x",
|
|
110
104
|
"release-6x": "git pull origin 6.x && git push origin 6.x && git push origin 6.x --tags && npm publish --tag 6x",
|
|
111
105
|
"mongo": "node ./tools/repl.js",
|
|
112
106
|
"test": "mocha --exit ./test/*.test.js",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
|
|
5
5
|
const stdin = fs.readFileSync(0).toString('utf8');
|
|
6
|
-
const maxInstantiations = isNaN(process.argv[2]) ?
|
|
6
|
+
const maxInstantiations = isNaN(process.argv[2]) ? 110000 : parseInt(process.argv[2], 10);
|
|
7
7
|
|
|
8
8
|
console.log(stdin);
|
|
9
9
|
|
package/types/expressions.d.ts
CHANGED
|
@@ -1150,6 +1150,21 @@ declare module 'mongoose' {
|
|
|
1150
1150
|
$first: Expression;
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
+
export interface FirstN {
|
|
1154
|
+
/**
|
|
1155
|
+
* $firstN can be used as an aggregation accumulator or array operator.
|
|
1156
|
+
* As an aggregation accumulator, it returns an aggregation of the first n elements within a group.
|
|
1157
|
+
* As an array operator, it returns the specified number of elements from the beginning of an array.
|
|
1158
|
+
*
|
|
1159
|
+
* @version 5.2
|
|
1160
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#mongodb-expression-exp.-first
|
|
1161
|
+
*/
|
|
1162
|
+
$firstN: {
|
|
1163
|
+
input: Expression
|
|
1164
|
+
n: Expression,
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1153
1168
|
export interface In {
|
|
1154
1169
|
/**
|
|
1155
1170
|
* Returns a boolean indicating whether a specified value is in an array.
|
|
@@ -1190,6 +1205,21 @@ declare module 'mongoose' {
|
|
|
1190
1205
|
$last: Expression;
|
|
1191
1206
|
}
|
|
1192
1207
|
|
|
1208
|
+
export interface LastN {
|
|
1209
|
+
/**
|
|
1210
|
+
* $lastN can be used as an aggregation accumulator or array operator.
|
|
1211
|
+
* As an aggregation accumulator, it an aggregation of the last n elements within a group.
|
|
1212
|
+
* As an array operator, it returns the specified number of elements from the end of an array.
|
|
1213
|
+
*
|
|
1214
|
+
* @version 5.2
|
|
1215
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#mongodb-group-grp.-lastN
|
|
1216
|
+
*/
|
|
1217
|
+
$lastN: {
|
|
1218
|
+
input: Expression
|
|
1219
|
+
n: Expression,
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1193
1223
|
export interface LinearFill {
|
|
1194
1224
|
/**
|
|
1195
1225
|
* Fills null and missing fields in a window using linear interpolation based on surrounding field values.
|
|
@@ -2000,6 +2030,34 @@ declare module 'mongoose' {
|
|
|
2000
2030
|
$avg: Expression;
|
|
2001
2031
|
}
|
|
2002
2032
|
|
|
2033
|
+
export interface Bottom {
|
|
2034
|
+
/**
|
|
2035
|
+
* Returns the bottom element within a group according to the specified sort order.
|
|
2036
|
+
*
|
|
2037
|
+
* @version 5.2
|
|
2038
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#mongodb-group-grp.-bottom
|
|
2039
|
+
*/
|
|
2040
|
+
$bottom: {
|
|
2041
|
+
sortBy: AnyObject,
|
|
2042
|
+
output: Expression
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
export interface BottomN {
|
|
2047
|
+
/**
|
|
2048
|
+
* Returns an aggregation of the bottom n elements within a group, according to the specified sort order.
|
|
2049
|
+
* If the group contains fewer than n elements, $bottomN returns all elements in the group.
|
|
2050
|
+
*
|
|
2051
|
+
* @version 5.2
|
|
2052
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#mongodb-group-grp.-bottomN
|
|
2053
|
+
*/
|
|
2054
|
+
$bottomN: {
|
|
2055
|
+
n: Expression,
|
|
2056
|
+
sortBy: AnyObject,
|
|
2057
|
+
output: Expression
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2003
2061
|
export interface Count {
|
|
2004
2062
|
/**
|
|
2005
2063
|
* Returns the number of documents in a group.
|
|
@@ -2158,6 +2216,20 @@ declare module 'mongoose' {
|
|
|
2158
2216
|
$max: Expression | Expression[];
|
|
2159
2217
|
}
|
|
2160
2218
|
|
|
2219
|
+
export interface MaxN {
|
|
2220
|
+
/**
|
|
2221
|
+
* Returns an aggregation of the maxmimum value n elements within a group.
|
|
2222
|
+
* If the group contains fewer than n elements, $maxN returns all elements in the group.
|
|
2223
|
+
*
|
|
2224
|
+
* @version 5.2
|
|
2225
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#mongodb-group-grp.-maxN
|
|
2226
|
+
*/
|
|
2227
|
+
$maxN: {
|
|
2228
|
+
input: Expression
|
|
2229
|
+
n: Expression,
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2161
2233
|
export interface Min {
|
|
2162
2234
|
/**
|
|
2163
2235
|
* Returns the minimum value. $min compares both value and type, using the specified BSON comparison order for
|
|
@@ -2169,6 +2241,20 @@ declare module 'mongoose' {
|
|
|
2169
2241
|
$min: Expression | Expression[];
|
|
2170
2242
|
}
|
|
2171
2243
|
|
|
2244
|
+
export interface MinN {
|
|
2245
|
+
/**
|
|
2246
|
+
* Returns an aggregation of the minimum value n elements within a group.
|
|
2247
|
+
* If the group contains fewer than n elements, $minN returns all elements in the group.
|
|
2248
|
+
*
|
|
2249
|
+
* @version 5.2
|
|
2250
|
+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#mongodb-group-grp.-minN
|
|
2251
|
+
*/
|
|
2252
|
+
$minN: {
|
|
2253
|
+
input: Expression
|
|
2254
|
+
n: Expression,
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2172
2258
|
export interface Push {
|
|
2173
2259
|
/**
|
|
2174
2260
|
* Returns an array of all values that result from applying an expression to documents.
|
|
@@ -2605,6 +2691,8 @@ declare module 'mongoose' {
|
|
|
2605
2691
|
export type ArrayExpressionOperatorReturningArray =
|
|
2606
2692
|
Expression.ConcatArrays |
|
|
2607
2693
|
Expression.Filter |
|
|
2694
|
+
Expression.FirstN |
|
|
2695
|
+
Expression.LastN |
|
|
2608
2696
|
Expression.Map |
|
|
2609
2697
|
Expression.ObjectToArray |
|
|
2610
2698
|
Expression.Range |
|
|
@@ -2763,12 +2851,16 @@ declare module 'mongoose' {
|
|
|
2763
2851
|
Expression.DocumentNumber |
|
|
2764
2852
|
Expression.ExpMovingAvg |
|
|
2765
2853
|
Expression.First |
|
|
2854
|
+
Expression.FirstN |
|
|
2766
2855
|
Expression.Integral |
|
|
2767
2856
|
Expression.Last |
|
|
2857
|
+
Expression.LastN |
|
|
2768
2858
|
Expression.LinearFill |
|
|
2769
2859
|
Expression.Locf |
|
|
2770
2860
|
Expression.Max |
|
|
2861
|
+
Expression.MaxN |
|
|
2771
2862
|
Expression.Min |
|
|
2863
|
+
Expression.MinN |
|
|
2772
2864
|
Expression.Push |
|
|
2773
2865
|
Expression.Rank |
|
|
2774
2866
|
Expression.Shift |
|
|
@@ -2783,6 +2875,10 @@ declare module 'mongoose' {
|
|
|
2783
2875
|
|
|
2784
2876
|
export type WindowOperatorReturningArray =
|
|
2785
2877
|
Expression.AddToSet |
|
|
2878
|
+
Expression.FirstN |
|
|
2879
|
+
Expression.LastN |
|
|
2880
|
+
Expression.MaxN |
|
|
2881
|
+
Expression.MinN |
|
|
2786
2882
|
Expression.Push;
|
|
2787
2883
|
|
|
2788
2884
|
export type WindowOperatorReturningNumber =
|
|
@@ -2858,12 +2954,18 @@ declare module 'mongoose' {
|
|
|
2858
2954
|
Expression.Accumulator |
|
|
2859
2955
|
Expression.AddToSet |
|
|
2860
2956
|
Expression.Avg |
|
|
2957
|
+
Expression.Bottom |
|
|
2958
|
+
Expression.BottomN |
|
|
2861
2959
|
Expression.Count |
|
|
2862
2960
|
Expression.First |
|
|
2961
|
+
Expression.FirstN |
|
|
2863
2962
|
Expression.Last |
|
|
2963
|
+
Expression.LastN |
|
|
2864
2964
|
Expression.Max |
|
|
2965
|
+
Expression.MaxN |
|
|
2865
2966
|
Expression.MergeObjects |
|
|
2866
2967
|
Expression.Min |
|
|
2968
|
+
Expression.MinN |
|
|
2867
2969
|
Expression.Push |
|
|
2868
2970
|
Expression.StdDevPop |
|
|
2869
2971
|
Expression.StdDevSamp |
|
package/types/query.d.ts
CHANGED
|
@@ -138,7 +138,15 @@ declare module 'mongoose' {
|
|
|
138
138
|
*/
|
|
139
139
|
returnDocument?: 'before' | 'after';
|
|
140
140
|
runValidators?: boolean;
|
|
141
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Set to `true` to automatically sanitize potentially unsafe user-generated query projections.
|
|
143
|
+
* Converts projection values that aren't numbers or booleans to `1`, including strings like `'$password'`
|
|
144
|
+
* and expressions like `{ $concat: ['$password'] }`, so projections can't copy one field's value into another.
|
|
145
|
+
* The only projection operators that are allowed are `$elemMatch`, `$slice` with numbers, and `$meta: 'textScore'`.
|
|
146
|
+
*
|
|
147
|
+
* In Mongoose 6, `sanitizeProjection` does **not** prevent projecting in fields that the schema deselects
|
|
148
|
+
* with `select: false`: `select('+password')` and `select({ password: 1 })` still include `password`.
|
|
149
|
+
*/
|
|
142
150
|
sanitizeProjection?: boolean;
|
|
143
151
|
/**
|
|
144
152
|
* Set to `true` to automatically sanitize potentially unsafe query filters by stripping out query selectors that
|