mongoose 5.13.8 → 5.13.9
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
CHANGED
|
@@ -417,7 +417,7 @@ function t(r){var n,o,i,s=Object.keys(r),a=s.length;for(;a--;)o=s[a],i=r[o],I.is
|
|
|
417
417
|
/*!
|
|
418
418
|
* Avoid Node deprecation warning DEP0079
|
|
419
419
|
*/
|
|
420
|
-
tt.prototype[C.custom]=tt.prototype.inspect),tt.prototype.toString=function(){var t=this.inspect();return"string"==typeof t?t:C(t)},tt.prototype.equals=function(t){if(!t)return!1;var e=this.$__getValue("_id"),r=null!=t.$__?t.$__getValue("_id"):t;return e||r?e&&e.equals?e.equals(r):e===r:U(this,t)},tt.prototype.populate=function(){if(0===arguments.length)return this;var t,e=this.$__.populate||(this.$__.populate={}),r=I.args(arguments);if("function"==typeof r[r.length-1]&&(t=r.pop()),r.length){var n,i=I.populate.apply(null,r),s=o(i);try{for(s.s();!(n=s.n()).done;){var a=n.value;e[a.path]=a}}catch(t){s.e(t)}finally{s.f()}}if(t){var u=I.object.vals(e);this.$__.populate=void 0;var c=this.constructor;if(this.$__isNested){c=this.$__[G].constructor;var l=this.$__.nestedPath;u.forEach((function(t){t.path=l+"."+t.path}))}if(null!=this.$session()){var f=this.$session();u.forEach((function(t){null!=t.options?"session"in t.options||(t.options.session=f):t.options={session:f}}))}c.populate(this,u,t)}return this},tt.prototype.$getPopulatedDocs=function(){var t=[];null!=this.$__.populated&&(t=t.concat(Object.keys(this.$__.populated))),null!=this.$$populatedVirtuals&&(t=t.concat(Object.keys(this.$$populatedVirtuals)));var e,r=[],n=o(t);try{for(n.s();!(e=n.n()).done;){var i=e.value,s=this.get(i);Array.isArray(s)?r=r.concat(s):s instanceof tt&&r.push(s)}}catch(t){n.e(t)}finally{n.f()}return r},tt.prototype.execPopulate=function(t){var e=this,r=null!=t&&"function"!=typeof t;return r?this.populate.apply(this,arguments).execPopulate():O(t,(function(t){e.populate(t)}),this.constructor.events)},tt.prototype.populated=function(t,e,r){if(null==e||!0===e){if(!this.$__.populated)return;var n=t.endsWith(".$*")?t.replace(/\.\$\*$/,""):t,o=this.$__.populated[n];return o?!0===e?o:o.value:void 0}this.$__.populated||(this.$__.populated={}),this.$__.populated[t]={value:e,options:r};for(var i=t.split("."),s=0;s<i.length-1;++s){var a=i.slice(0,s+1).join("."),u=this.get(a);if(null!=u&&null!=u.$__&&this.populated(a)){var c=i.slice(s+1).join(".");u.populated(c,e,r);break}}return e},tt.prototype.depopulate=function(t){var e;"string"==typeof t&&(t=t.split(" "));var r=this.$$populatedVirtuals?Object.keys(this.$$populatedVirtuals):[],n=j(this,"$__.populated",{});if(0===arguments.length){var i,s=o(r);try{for(s.s();!(i=s.n()).done;){var a=i.value;delete this.$$populatedVirtuals[a],delete this._doc[a],delete n[a]}}catch(t){s.e(t)}finally{s.f()}for(var u=Object.keys(n),c=0,l=u;c<l.length;c++){var f=l[c];(e=this.populated(f))&&(delete n[f],
|
|
420
|
+
tt.prototype[C.custom]=tt.prototype.inspect),tt.prototype.toString=function(){var t=this.inspect();return"string"==typeof t?t:C(t)},tt.prototype.equals=function(t){if(!t)return!1;var e=this.$__getValue("_id"),r=null!=t.$__?t.$__getValue("_id"):t;return e||r?e&&e.equals?e.equals(r):e===r:U(this,t)},tt.prototype.populate=function(){if(0===arguments.length)return this;var t,e=this.$__.populate||(this.$__.populate={}),r=I.args(arguments);if("function"==typeof r[r.length-1]&&(t=r.pop()),r.length){var n,i=I.populate.apply(null,r),s=o(i);try{for(s.s();!(n=s.n()).done;){var a=n.value;e[a.path]=a}}catch(t){s.e(t)}finally{s.f()}}if(t){var u=I.object.vals(e);this.$__.populate=void 0;var c=this.constructor;if(this.$__isNested){c=this.$__[G].constructor;var l=this.$__.nestedPath;u.forEach((function(t){t.path=l+"."+t.path}))}if(null!=this.$session()){var f=this.$session();u.forEach((function(t){null!=t.options?"session"in t.options||(t.options.session=f):t.options={session:f}}))}c.populate(this,u,t)}return this},tt.prototype.$getPopulatedDocs=function(){var t=[];null!=this.$__.populated&&(t=t.concat(Object.keys(this.$__.populated))),null!=this.$$populatedVirtuals&&(t=t.concat(Object.keys(this.$$populatedVirtuals)));var e,r=[],n=o(t);try{for(n.s();!(e=n.n()).done;){var i=e.value,s=this.get(i);Array.isArray(s)?r=r.concat(s):s instanceof tt&&r.push(s)}}catch(t){n.e(t)}finally{n.f()}return r},tt.prototype.execPopulate=function(t){var e=this,r=null!=t&&"function"!=typeof t;return r?this.populate.apply(this,arguments).execPopulate():O(t,(function(t){e.populate(t)}),this.constructor.events)},tt.prototype.populated=function(t,e,r){if(null==e||!0===e){if(!this.$__.populated)return;var n=t.endsWith(".$*")?t.replace(/\.\$\*$/,""):t,o=this.$__.populated[n];return o?!0===e?o:o.value:void 0}this.$__.populated||(this.$__.populated={}),this.$__.populated[t]={value:e,options:r};for(var i=t.split("."),s=0;s<i.length-1;++s){var a=i.slice(0,s+1).join("."),u=this.get(a);if(null!=u&&null!=u.$__&&this.populated(a)){var c=i.slice(s+1).join(".");u.populated(c,e,r);break}}return e},tt.prototype.depopulate=function(t){var e;"string"==typeof t&&(t=t.split(" "));var r=this.$$populatedVirtuals?Object.keys(this.$$populatedVirtuals):[],n=j(this,"$__.populated",{});if(0===arguments.length){var i,s=o(r);try{for(s.s();!(i=s.n()).done;){var a=i.value;delete this.$$populatedVirtuals[a],delete this._doc[a],delete n[a]}}catch(t){s.e(t)}finally{s.f()}for(var u=Object.keys(n),c=0,l=u;c<l.length;c++){var f=l[c];(e=this.populated(f))&&(delete n[f],I.setValue(f,e,this._doc))}return this}var p,h=o(t);try{for(h.s();!(p=h.n()).done;){var y=p.value;e=this.populated(y),delete n[y],-1!==r.indexOf(y)?(delete this.$$populatedVirtuals[y],delete this._doc[y]):e&&I.setValue(y,e,this._doc)}}catch(t){h.e(t)}finally{h.f()}return this},tt.prototype.$__fullPath=function(t){return t||""},tt.prototype.getChanges=function(){var t=this.$__delta();return t?t[1]:{}},
|
|
421
421
|
/*!
|
|
422
422
|
* Module exports.
|
|
423
423
|
*/
|
|
@@ -1092,11 +1092,11 @@ o.prototype.map=function(){return this.map=this._iter("map"),this.map.apply(this
|
|
|
1092
1092
|
/*!
|
|
1093
1093
|
* Returns the value passed to it.
|
|
1094
1094
|
*/
|
|
1095
|
-
function s(t){return t}e.get=function(t,r,
|
|
1095
|
+
function s(t){return t}e.get=function(t,r,i,a){var u;"function"==typeof i&&(i.length<2?(a=i,i=void 0):(u=i,i=void 0)),a||(a=s);var c="string"==typeof t?o(t):t;if(!Array.isArray(c))throw new TypeError("Invalid `path`. Must be either string or array");for(var l,f=r,p=0;p<c.length;++p){if(l=c[p],"string"!=typeof c[p]&&"number"!=typeof c[p])throw new TypeError("Each segment of path to `get()` must be a string or number, got "+n(c[p]));if(Array.isArray(f)&&!/^\d+$/.test(l)){var h=c.slice(p);return[].concat(f).map((function(t){return t?e.get(h,t,i||u,a):a(void 0)}))}if(u)f=u(f,l);else{var y=i&&f[i]?f[i]:f;f=y instanceof Map?y.get(l):y[l]}if(!f)return a(f)}return a(f)},e.has=function(t,e){var r="string"==typeof t?o(t):t;if(!Array.isArray(r))throw new TypeError("Invalid `path`. Must be either string or array");for(var i=r.length,s=e,a=0;a<i;++a){if("string"!=typeof r[a]&&"number"!=typeof r[a])throw new TypeError("Each segment of path to `has()` must be a string or number, got "+n(r[a]));if(null==s||"object"!==n(s)||!(r[a]in s))return!1;s=s[r[a]]}return!0},e.unset=function(t,e){var r="string"==typeof t?o(t):t;if(!Array.isArray(r))throw new TypeError("Invalid `path`. Must be either string or array");for(var s=r.length,a=e,u=0;u<s;++u){if(null==a||"object"!==n(a)||!(r[u]in a))return!1;if("string"!=typeof r[u]&&"number"!=typeof r[u])throw new TypeError("Each segment of path to `unset()` must be a string or number, got "+n(r[u]));if(-1!==i.indexOf(r[u]))return!1;if(u===s-1)return delete a[r[u]],!0;a=a instanceof Map?a.get(r[u]):a[r[u]]}return!0},e.set=function(t,r,a,u,c,l){var f;"function"==typeof u&&(u.length<2?(c=u,u=void 0):(f=u,u=void 0)),c||(c=s);var p="string"==typeof t?o(t):t;if(!Array.isArray(p))throw new TypeError("Invalid `path`. Must be either string or array");if(null!=a){for(var h=0;h<p.length;++h){if("string"!=typeof p[h]&&"number"!=typeof p[h])throw new TypeError("Each segment of path to `set()` must be a string or number, got "+n(p[h]));if(-1!==i.indexOf(p[h]))return}for(var y,d=l||/\$/.test(t)&&!1!==l,_=a,v=(h=0,p.length-1);h<v;++h)if("$"!=(y=p[h])){if(Array.isArray(_)&&!/^\d+$/.test(y)){var m=p.slice(h);if(!d&&Array.isArray(r))for(var g=0;g<_.length&&g<r.length;++g)e.set(m,r[g],_[g],u||f,c,d);else for(g=0;g<_.length;++g)e.set(m,r,_[g],u||f,c,d);return}if(f)_=f(_,y);else{var b=u&&_[u]?_[u]:_;_=b instanceof Map?b.get(y):b[y]}if(!_)return}else if(h==v-1)break;if(y=p[v],u&&_[u]&&(_=_[u]),Array.isArray(_)&&!/^\d+$/.test(y))if(!d&&Array.isArray(r))!
|
|
1096
1096
|
/*!
|
|
1097
1097
|
* Recursively set nested arrays
|
|
1098
1098
|
*/
|
|
1099
|
-
function t(e,r,n,o,i,s){for(var a,u=0;u<e.length&&u<r.length;++u)a=e[u],Array.isArray(a)&&Array.isArray(r[u])?t(a,r[u],n,o,i,s):a&&(o?o(a,n,s(r[u])):(a[i]&&(a=a[i]),a[n]=s(r[u])))}(
|
|
1099
|
+
function t(e,r,n,o,i,s){for(var a,u=0;u<e.length&&u<r.length;++u)a=e[u],Array.isArray(a)&&Array.isArray(r[u])?t(a,r[u],n,o,i,s):a&&(o?o(a,n,s(r[u])):(a[i]&&(a=a[i]),a[n]=s(r[u])))}(_,r,y,f,u,c);else for(g=0;g<_.length;++g){var w=_[g];w&&(f?f(w,y,c(r)):(w[u]&&(w=w[u]),w[y]=c(r)))}else f?f(_,y,c(r)):_ instanceof Map?_.set(y,c(r)):_[y]=c(r)}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=[],r="",n="DEFAULT",o=0;o<t.length;++o)"IN_SQUARE_BRACKETS"!==n||/\d/.test(t[o])||"]"===t[o]||(n="DEFAULT",r=e[e.length-1]+"["+r,e.splice(e.length-1,1)),"["===t[o]?("IMMEDIATELY_AFTER_SQUARE_BRACKETS"!==n&&(e.push(r),r=""),n="IN_SQUARE_BRACKETS"):"]"===t[o]?"IN_SQUARE_BRACKETS"===n?(n="IMMEDIATELY_AFTER_SQUARE_BRACKETS",e.push(r),r=""):(n="DEFAULT",r+=t[o]):"."===t[o]?("IMMEDIATELY_AFTER_SQUARE_BRACKETS"!==n&&(e.push(r),r=""),n="DEFAULT"):r+=t[o];return"IMMEDIATELY_AFTER_SQUARE_BRACKETS"!==n&&e.push(r),e}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=r(26);t.exports=function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._docs={},this._childDocs=[],null!=e&&(e=o(e),Object.assign(this,e),"object"===n(e.subPopulate)&&(this.populate=e.subPopulate),null!=e.perDocumentLimit&&null!=e.limit))throw new Error("Can not use `limit` and `perDocumentLimit` at the same time. Path: `"+e.path+"`.")}},function(t,e,r){"use strict";
|
|
1100
1100
|
/*
|
|
1101
1101
|
object-assign
|
|
1102
1102
|
(c) Sindre Sorhus
|
package/index.d.ts
CHANGED
|
@@ -1748,7 +1748,8 @@ declare module 'mongoose' {
|
|
|
1748
1748
|
> = PopulatedType | RawId;
|
|
1749
1749
|
|
|
1750
1750
|
interface IndexOptions extends mongodb.IndexOptions {
|
|
1751
|
-
expires?: number | string
|
|
1751
|
+
expires?: number | string;
|
|
1752
|
+
weights?: AnyObject;
|
|
1752
1753
|
}
|
|
1753
1754
|
|
|
1754
1755
|
interface ValidatorProps {
|
|
@@ -2535,40 +2536,29 @@ declare module 'mongoose' {
|
|
|
2535
2536
|
|
|
2536
2537
|
type NumericTypes = number | mongodb.Decimal128 | mongodb.Double | mongodb.Int32 | mongodb.Long;
|
|
2537
2538
|
|
|
2538
|
-
type
|
|
2539
|
-
[key in keyof TSchema]
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
type PullOperator<TSchema> = {
|
|
2543
|
-
[key in KeysOfAType<TSchema, ReadonlyArray<any>>]?:
|
|
2544
|
-
| Partial<Unpacked<TSchema[key]>>
|
|
2545
|
-
| mongodb.ObjectQuerySelector<Unpacked<TSchema[key]>>
|
|
2546
|
-
// Doesn't look like TypeScript has good support for creating an
|
|
2547
|
-
// object containing dotted keys:
|
|
2548
|
-
// https://stackoverflow.com/questions/58434389/typescript-deep-keyof-of-a-nested-object
|
|
2549
|
-
| mongodb.QuerySelector<any>
|
|
2550
|
-
| any;
|
|
2551
|
-
} | any; // Because TS doesn't have good support for creating an object with dotted keys, including `.$.` re: #10075
|
|
2539
|
+
type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = {
|
|
2540
|
+
[key in keyof TSchema]?: [Extract<TSchema[key], FieldType>] extends [never] ? never : AssignableType;
|
|
2541
|
+
};
|
|
2552
2542
|
|
|
2553
2543
|
/** @see https://docs.mongodb.com/manual/reference/operator/update */
|
|
2554
2544
|
type _UpdateQuery<TSchema> = {
|
|
2555
2545
|
/** @see https://docs.mongodb.com/manual/reference/operator/update-field/ */
|
|
2556
|
-
$currentDate?:
|
|
2557
|
-
$inc?:
|
|
2558
|
-
$min?:
|
|
2559
|
-
$max?:
|
|
2560
|
-
$mul?:
|
|
2546
|
+
$currentDate?: OnlyFieldsOfType<TSchema, NativeDate, true | { $type: 'date' | 'timestamp' }> & AnyObject;
|
|
2547
|
+
$inc?: OnlyFieldsOfType<TSchema, NumericTypes | undefined> & AnyObject;
|
|
2548
|
+
$min?: OnlyFieldsOfType<TSchema, any, any> & AnyObject;
|
|
2549
|
+
$max?: OnlyFieldsOfType<TSchema, any, any> & AnyObject;
|
|
2550
|
+
$mul?: OnlyFieldsOfType<TSchema, NumericTypes | undefined> & AnyObject;
|
|
2561
2551
|
$rename?: { [key: string]: string };
|
|
2562
|
-
$set?:
|
|
2563
|
-
$setOnInsert?:
|
|
2564
|
-
$unset?:
|
|
2552
|
+
$set?: OnlyFieldsOfType<TSchema, any, any> & AnyObject;
|
|
2553
|
+
$setOnInsert?: OnlyFieldsOfType<TSchema, any, any> & AnyObject;
|
|
2554
|
+
$unset?: OnlyFieldsOfType<TSchema, any, any> & AnyObject;
|
|
2565
2555
|
|
|
2566
2556
|
/** @see https://docs.mongodb.com/manual/reference/operator/update-array/ */
|
|
2567
|
-
$addToSet?:
|
|
2568
|
-
$pop?:
|
|
2569
|
-
$pull?:
|
|
2570
|
-
$push?:
|
|
2571
|
-
$pullAll?:
|
|
2557
|
+
$addToSet?: OnlyFieldsOfType<TSchema, any[], any> & AnyObject;
|
|
2558
|
+
$pop?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, 1 | -1> & AnyObject;
|
|
2559
|
+
$pull?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, any> & AnyObject;
|
|
2560
|
+
$push?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, any> & AnyObject;
|
|
2561
|
+
$pullAll?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, any> & AnyObject;
|
|
2572
2562
|
|
|
2573
2563
|
/** @see https://docs.mongodb.com/manual/reference/operator/update-bitwise/ */
|
|
2574
2564
|
$bit?: {
|
|
@@ -2584,7 +2574,18 @@ declare module 'mongoose' {
|
|
|
2584
2574
|
{ $replaceRoot: any } |
|
|
2585
2575
|
{ $replaceWith: any };
|
|
2586
2576
|
|
|
2587
|
-
|
|
2577
|
+
type __UpdateDefProperty<T> =
|
|
2578
|
+
0 extends (1 & T) ? T : // any
|
|
2579
|
+
T extends unknown[] ? LeanArray<T> : // Array
|
|
2580
|
+
T extends Document ? LeanDocument<T> : // Subdocument
|
|
2581
|
+
[Extract<T, mongodb.ObjectId>] extends [never] ? T :
|
|
2582
|
+
T | string;
|
|
2583
|
+
type __UpdateQueryDef<T> = {
|
|
2584
|
+
[K in keyof T]: __UpdateDefProperty<T[K]>;
|
|
2585
|
+
};
|
|
2586
|
+
type _UpdateQueryDef<T> = __UpdateQueryDef<T>;
|
|
2587
|
+
|
|
2588
|
+
export type UpdateQuery<T> = (_UpdateQuery<_UpdateQueryDef<T>> & mongodb.MatchKeysAndValues<_UpdateQueryDef<LeanDocument<T>>>);
|
|
2588
2589
|
|
|
2589
2590
|
type _AllowStringsForIds<T> = {
|
|
2590
2591
|
[K in keyof T]: [Extract<T[K], mongodb.ObjectId>] extends [never]
|
package/lib/document.js
CHANGED
|
@@ -4203,7 +4203,7 @@ Document.prototype.depopulate = function(path) {
|
|
|
4203
4203
|
continue;
|
|
4204
4204
|
}
|
|
4205
4205
|
delete populated[key];
|
|
4206
|
-
|
|
4206
|
+
utils.setValue(key, populatedIds, this._doc);
|
|
4207
4207
|
}
|
|
4208
4208
|
return this;
|
|
4209
4209
|
}
|
|
@@ -4216,7 +4216,7 @@ Document.prototype.depopulate = function(path) {
|
|
|
4216
4216
|
delete this.$$populatedVirtuals[singlePath];
|
|
4217
4217
|
delete this._doc[singlePath];
|
|
4218
4218
|
} else if (populatedIds) {
|
|
4219
|
-
|
|
4219
|
+
utils.setValue(singlePath, populatedIds, this._doc);
|
|
4220
4220
|
}
|
|
4221
4221
|
}
|
|
4222
4222
|
return this;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "5.13.
|
|
4
|
+
"version": "5.13.9",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
],
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@types/bson": "1.x || 4.0.x",
|
|
22
23
|
"@types/mongodb": "^3.5.27",
|
|
23
24
|
"bson": "^1.1.4",
|
|
24
25
|
"kareem": "2.3.2",
|
|
25
26
|
"mongodb": "3.6.11",
|
|
26
27
|
"mongoose-legacy-pluralize": "1.0.2",
|
|
27
|
-
"mpath": "0.8.
|
|
28
|
+
"mpath": "0.8.4",
|
|
28
29
|
"mquery": "3.2.5",
|
|
29
30
|
"ms": "2.1.2",
|
|
30
31
|
"optional-require": "1.0.x",
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
"build-browser": "node build-browser.js",
|
|
79
80
|
"prepublishOnly": "npm run build-browser",
|
|
80
81
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
81
|
-
"release-legacy": "git pull origin
|
|
82
|
+
"release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy",
|
|
82
83
|
"test": "mocha --exit ./test/*.test.js ./test/typescript/main.test.js",
|
|
83
84
|
"tdd": "mocha ./test/*.test.js ./test/typescript/main.test.js --watch --recursive --watch-files ./**/*.js",
|
|
84
85
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|