mongoose 5.11.7 → 5.11.8
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/History.md +9 -0
- package/dist/browser.umd.js +4 -4
- package/index.d.ts +37 -14
- package/package.json +1 -1
package/History.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
5.11.8 / 2020-12-14
|
|
2
|
+
===================
|
|
3
|
+
* fix(index.d.ts): add missing single document populate #9696 [YC](https://github.com/YC)
|
|
4
|
+
* fix(index.d.ts): make options optional for `toObject` #9700
|
|
5
|
+
* fix(index.d.ts): added missing match and model methods in Aggregate class #9710 [manekshms](https://github.com/manekshms)
|
|
6
|
+
* fix(index.d.ts): make options optional for `createIndexes()` and `ensureIndexes()` #9706
|
|
7
|
+
* fix(index.d.ts): support passing a function to `ValidateOpts.message` #9697
|
|
8
|
+
* docs: add media query for ::before on headings #9705 #9704 [YC](https://github.com/YC)
|
|
9
|
+
|
|
1
10
|
5.11.7 / 2020-12-10
|
|
2
11
|
===================
|
|
3
12
|
* fix(document): ensure calling `get()` with empty string returns undefined for mongoose-plugin-autoinc #9681
|
package/dist/browser.umd.js
CHANGED
|
@@ -752,11 +752,11 @@ i.set(e.Promise),t.exports=i}).call(this,r(11))},function(t,e,r){"use strict";(f
|
|
|
752
752
|
/*!
|
|
753
753
|
* Module dependencies.
|
|
754
754
|
*/
|
|
755
|
-
function o(t){return(o="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 i=r(118).Buffer,s=r(64),a=
|
|
755
|
+
function o(t){return(o="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 i=r(118).Buffer,s=r(64),a=e.clone=function t(r,n){if(null==r)return r;if(Array.isArray(r))return e.cloneArray(r,n);if(r.constructor){if(/ObjectI[dD]$/.test(r.constructor.name))return"function"==typeof r.clone?r.clone():new r.constructor(r.id);if("ReadPreference"===r.constructor.name)return new r.constructor(r.mode,t(r.tags,n));if("Binary"==r._bsontype&&r.buffer&&r.value)return"function"==typeof r.clone?r.clone():new r.constructor(r.value(!0),r.sub_type);if("Date"===r.constructor.name||"Function"===r.constructor.name)return new r.constructor(+r);if("RegExp"===r.constructor.name)return s(r);if("Buffer"===r.constructor.name)return e.cloneBuffer(r)}return c(r)?e.cloneObject(r,n):r.valueOf?r.valueOf():void 0};
|
|
756
756
|
/*!
|
|
757
757
|
* ignore
|
|
758
758
|
*/
|
|
759
|
-
e.cloneObject=function(t,e){var r,n,o,i=e&&e.minimize,s={};for(o in t)
|
|
759
|
+
e.cloneObject=function(t,e){var r,n,o,i=e&&e.minimize,s={};for(o in t)n=a(t[o],e),i&&void 0===n||(r||(r=!0),s[o]=n);return i?r&&s:s},e.cloneArray=function(t,e){for(var r=[],n=0,o=t.length;n<o;n++)r.push(a(t[n],e));return r},e.tick=function(t){if("function"==typeof t)return function(){var e=arguments;l((function(){t.apply(this,e)}))}},e.merge=function t(r,n){for(var o,i=Object.keys(n),s=i.length;s--;)void 0===r[o=i[s]]?r[o]=n[o]:e.isObject(n[o])?t(r[o],n[o]):r[o]=n[o]},e.mergeClone=function t(r,n){for(var o,i=Object.keys(n),s=i.length;s--;)void 0===r[o=i[s]]?r[o]=a(n[o]):e.isObject(n[o])?t(r[o],n[o]):r[o]=a(n[o])},e.readPref=function(t){switch(t){case"p":t="primary";break;case"pp":t="primaryPreferred";break;case"s":t="secondary";break;case"sp":t="secondaryPreferred";break;case"n":t="nearest"}return t},e.readConcern=function(t){if("string"==typeof t){switch(t){case"l":t="local";break;case"a":t="available";break;case"m":t="majority";break;case"lz":t="linearizable";break;case"s":t="snapshot"}t={level:t}}return t};var u=Object.prototype.toString;e.toString=function(t){return u.call(t)};var c=e.isObject=function(t){return"[object Object]"==e.toString(t)};e.isArray=function(t){return Array.isArray(t)||"object"==o(t)&&"[object Array]"==e.toString(t)},e.keys=Object.keys||function(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e},e.create="function"==typeof Object.create?Object.create:function(t){if(arguments.length>1)throw new Error("Adding properties is not supported");function e(){}return e.prototype=t,new e},e.inherits=function(t,r){t.prototype=e.create(r.prototype),t.prototype.constructor=t};var l=e.soon="function"==typeof t?t:n.nextTick;e.cloneBuffer=function(t){var e=i.alloc(t.length);return t.copy(e,0,0,t.length),e},e.isArgumentsObject=function(t){return"[object Arguments]"===Object.prototype.toString.call(t)}}).call(this,r(69).setImmediate,r(8))},function(t,e,r){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new i(o.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new i(o.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(117),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(11))},function(t,e,r){"use strict";(function(t,r,n,o){function i(t){return(i="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)}e.isNode=void 0!==t&&"object"==i(r)&&"object"==(void 0===n?"undefined":i(n))&&"function"==typeof o&&t.argv,e.isMongo=!e.isNode&&"function"==typeof printjson&&"function"==typeof ObjectId&&"function"==typeof rs&&"function"==typeof sh,e.isBrowser=!e.isNode&&!e.isMongo&&"undefined"!=typeof window,e.type=e.isNode?"node":e.isMongo?"mongo":e.isBrowser?"browser":"unknown"}).call(this,r(8),r(123)(t),r(11),r(1).Buffer)},function(t,e,r){"use strict";
|
|
760
760
|
/*!
|
|
761
761
|
* Module dependencies.
|
|
762
762
|
*/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)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=u(t);if(e){var o=u(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return a(this,r)}}function a(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var c=r(5),l=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(u,t);var e,r,n,a=s(u);function u(t){var e;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u);var r=t.message;r||(r=c.messages.general.default);var n=f(r,t);return e=a.call(this,n),t=Object.assign({},t,{message:n}),e.properties=t,e.kind=t.type,e.path=t.path,e.value=t.value,e.reason=t.reason,e}
|
|
@@ -1073,7 +1073,7 @@ function s(t){return t}e.get=function(t,r,n,i){var a;"function"==typeof n&&(n.le
|
|
|
1073
1073
|
/*!
|
|
1074
1074
|
* Recursively set nested arrays
|
|
1075
1075
|
*/
|
|
1076
|
-
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])))}(d,r,h,l,a,u);else for(v=0;v<d.length;++v)item=d[v],item&&(l?l(item,h,u(r)):(item[a]&&(item=item[a]),item[h]=u(r)));else l?l(d,h,u(r)):d instanceof Map?d.set(h,u(r)):d[h]=u(r)}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=[],r="",n=!1,o=0;o<t.length;++o){if(n&&!/\d/.test(t[o])&&"]"!==t[o])throw new Error('Can only use numbers in square bracket path notation, got character "'+t[o]+'" in path "'+t+'"');"."===t[o]||"["===t[o]||"]"===t[o]?("["===t[o]?n=!0:"]"===t[o]&&(n=!1),r.length>0&&e.push(r),r=""):r+=t[o]}return 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(28);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";
|
|
1076
|
+
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])))}(d,r,h,l,a,u);else for(v=0;v<d.length;++v)item=d[v],item&&(l?l(item,h,u(r)):(item[a]&&(item=item[a]),item[h]=u(r)));else l?l(d,h,u(r)):d instanceof Map?d.set(h,u(r)):d[h]=u(r)}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=[],r="",n=!1,o=0;o<t.length;++o){if(n&&!/\d/.test(t[o])&&"]"!==t[o])throw new Error('Can only use numbers in square bracket path notation, got character "'+t[o]+'" in path "'+t+'"');"."===t[o]||"["===t[o]||"]"===t[o]?("["===t[o]?n=!0:"]"===t[o]&&(n=!1),r.length>0&&e.push(r),r=""):r+=t[o]}return r.length>0&&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(28);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";
|
|
1077
1077
|
/*
|
|
1078
1078
|
object-assign
|
|
1079
1079
|
(c) Sindre Sorhus
|
|
@@ -1201,7 +1201,7 @@ t.exports=u},function(t,e,r){"use strict";var n=r(32);
|
|
|
1201
1201
|
/*!
|
|
1202
1202
|
* exports
|
|
1203
1203
|
*/
|
|
1204
|
-
t.exports=u},function(t,e,r){"use strict";(function(e){function r(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return(o="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)}function i(){this._pres=new Map,this._posts=new Map}function s(t,e,r,n,o,i,s){if(i.useErrorHandlers){var a={error:e};return t.execPost(r,n,o,a,(function(t){return"function"==typeof s&&s(t)}))}return"function"==typeof s?s(e):void 0}function a(t,e,r){return t.has(e)?t.get(e):r}function u(t,e,r,n){var o;try{o=t.apply(e,r)}catch(t){return n(t)}c(o)&&o.then((function(){return n()}),(function(t){return n(t)}))}function c(t){return null!=t&&"function"==typeof t.then}function l(t){var r=!1,n=this;return function(){var o=arguments;if(!r)return r=!0,e.nextTick((function(){return t.apply(n,o)}))}}i.prototype.execPre=function(t,r,n,o){3===arguments.length&&(o=n,n=[]);var i=a(this._pres,t,[]),s=i.length,f=i.numAsync||0,p=0,h=f,y=!1,d=n;if(!s)return e.nextTick((function(){o(null)}));var _=function t(){if(!(p>=s)){var n=i[p];if(n.isAsync){var a=[l(m),l((function(t){if(t){if(y)return;return y=!0,o(t)}if(0==--h&&p>=s)return o(null)}))];u(n.fn,r,a,a[0])}else if(n.fn.length>0){a=[l(m)];for(var f=arguments.length>=2?arguments:[null].concat(d),_=1;_<f.length;++_)a.push(f[_]);u(n.fn,r,a,a[0])}else{var v=null;try{
|
|
1204
|
+
t.exports=u},function(t,e,r){"use strict";(function(e){function r(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return(o="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)}function i(){this._pres=new Map,this._posts=new Map}function s(t,e,r,n,o,i,s){if(i.useErrorHandlers){var a={error:e};return t.execPost(r,n,o,a,(function(t){return"function"==typeof s&&s(t)}))}return"function"==typeof s?s(e):void 0}function a(t,e,r){return t.has(e)?t.get(e):r}function u(t,e,r,n){var o;try{o=t.apply(e,r)}catch(t){return n(t)}c(o)&&o.then((function(){return n()}),(function(t){return n(t)}))}function c(t){return null!=t&&"function"==typeof t.then}function l(t){var r=!1,n=this;return function(){var o=arguments;if(!r)return r=!0,e.nextTick((function(){return t.apply(n,o)}))}}i.prototype.execPre=function(t,r,n,o){3===arguments.length&&(o=n,n=[]);var i=a(this._pres,t,[]),s=i.length,f=i.numAsync||0,p=0,h=f,y=!1,d=n;if(!s)return e.nextTick((function(){o(null)}));var _=function t(){if(!(p>=s)){var n=i[p];if(n.isAsync){var a=[l(m),l((function(t){if(t){if(y)return;return y=!0,o(t)}if(0==--h&&p>=s)return o(null)}))];u(n.fn,r,a,a[0])}else if(n.fn.length>0){a=[l(m)];for(var f=arguments.length>=2?arguments:[null].concat(d),_=1;_<f.length;++_)a.push(f[_]);u(n.fn,r,a,a[0])}else{var v=null,g=null;try{g=n.fn.call(r)}catch(t){v=t}if(c(g))g.then((function(){return m()}),(function(t){return m(t)}));else{if(++p>=s)return h>0?void 0:e.nextTick((function(){o(v)}));t(v)}}}};function m(t){if(t){if(y)return;return y=!0,o(t)}if(++p>=s)return h>0?void 0:o(null);_.apply(r,arguments)}_.apply(null,[null].concat(n))},i.prototype.execPreSync=function(t,e,r){for(var n=a(this._pres,t,[]),o=n.length,i=0;i<o;++i)n[i].fn.apply(e,r||[])},i.prototype.execPost=function(t,r,n,o,i){arguments.length<5&&(i=o,o=null);var s=a(this._posts,t,[]),f=s.length,p=0,h=null;if(o&&o.error&&(h=o.error),!f)return e.nextTick((function(){i.apply(null,[h].concat(n))}));var y=function t(){for(var e=s[p].fn,o=0,a=n.length,y=[],d=0;d<a;++d)o+=n[d]&&n[d]._kareemIgnore?0:1,n[d]&&n[d]._kareemIgnore||y.push(n[d]);if(h)if(e.length===o+2){var _=l((function(e){if(e&&(h=e),++p>=f)return i.call(null,h);t()}));u(e,r,[h].concat(y).concat([_]),_)}else{if(++p>=f)return i.call(null,h);t()}else{var m=l((function(e){return e?(h=e,t()):++p>=f?i.apply(null,[null].concat(n)):void t()}));if(e.length===o+2)return++p>=f?i.apply(null,[null].concat(n)):t();if(e.length===o+1)u(e,r,y.concat([m]),m);else{var v,g;try{g=e.apply(r,y)}catch(t){v=t,h=t}if(c(g))return g.then((function(){return m()}),(function(t){return m(t)}));if(++p>=f)return i.apply(null,[v].concat(n));t()}}};y()},i.prototype.execPostSync=function(t,e,r){for(var n=a(this._posts,t,[]),o=n.length,i=0;i<o;++i)n[i].fn.apply(e,r||[])},i.prototype.createWrapperSync=function(t,e){var r=this;return function(){r.execPreSync(t,this,arguments);var n=e.apply(this,arguments);return r.execPostSync(t,this,[n]),n}},i.prototype.wrap=function(t,e,r,n,o){var i=n.length>0?n[n.length-1]:null,a=("function"==typeof i&&n.slice(0,n.length-1),this),u=(o=o||{}).checkForPromise;this.execPre(t,r,n,(function(c){if(c){for(var l=o.numCallbackParams||0,f=o.contextParameter?[r]:[],p=f.length;p<l;++p)f.push(null);return s(a,c,t,r,f,o,i)}var h="function"==typeof i?n.length-1:n.length,y=e.length,d=e.apply(r,n.slice(0,h).concat(_));if(u){if(null!=d&&"function"==typeof d.then)return d.then((function(t){return _(null,t)}),(function(t){return _(t)}));if(y<h+1)return _(null,d)}function _(){var e=Array.prototype.slice.call(arguments,1);if(o.nullResultByDefault&&0===e.length&&e.push(null),arguments[0])return s(a,arguments[0],t,r,e,o,i);a.execPost(t,r,e,(function(){return arguments[0]?"function"==typeof i?i(arguments[0]):void 0:"function"==typeof i?i.apply(r,arguments):void 0}))}}))},i.prototype.filter=function(t){for(var e=this,r=this.clone(),n=Array.from(r._pres.keys()),o=function(){var n=s[i],o=e._pres.get(n).map((function(t){return Object.assign({},t,{name:n})})).filter(t);if(0===o.length)return r._pres.delete(n),"continue";o.numAsync=o.filter((function(t){return t.isAsync})).length,r._pres.set(n,o)},i=0,s=n;i<s.length;i++)o();for(var a=Array.from(r._posts.keys()),u=function(){var n=l[c],o=e._posts.get(n).map((function(t){return Object.assign({},t,{name:n})})).filter(t);if(0===o.length)return r._posts.delete(n),"continue";r._posts.set(n,o)},c=0,l=a;c<l.length;c++)u();return r},i.prototype.hasHooks=function(t){return this._pres.has(t)||this._posts.has(t)},i.prototype.createWrapper=function(t,r,n,o){var i=this;return this.hasHooks(t)?function(){var e=n||this,s=Array.prototype.slice.call(arguments);i.wrap(t,r,e,s,o)}:function(){var t=arguments,n=this;e.nextTick((function(){return r.apply(n,t)}))}},i.prototype.pre=function(t,e,r,n,i){var s={};"object"===o(e)&&null!=e?e=(s=e).isAsync:"boolean"!=typeof arguments[1]&&(n=r,r=e,e=!1);var u=a(this._pres,t,[]);if(this._pres.set(t,u),e&&(u.numAsync=u.numAsync||0,++u.numAsync),"function"!=typeof r)throw new Error('pre() requires a function, got "'+o(r)+'"');return i?u.unshift(Object.assign({},s,{fn:r,isAsync:e})):u.push(Object.assign({},s,{fn:r,isAsync:e})),this},i.prototype.post=function(t,e,r,n){var i=a(this._posts,t,[]);if("function"==typeof e&&(n=!!r,r=e,e={}),"function"!=typeof r)throw new Error('post() requires a function, got "'+o(r)+'"');return n?i.unshift(Object.assign({},e,{fn:r})):i.push(Object.assign({},e,{fn:r})),this._posts.set(t,i),this},i.prototype.clone=function(){var t,e=new i,n=r(this._pres.keys());try{for(n.s();!(t=n.n()).done;){var o=t.value,s=this._pres.get(o).slice();s.numAsync=this._pres.get(o).numAsync,e._pres.set(o,s)}}catch(t){n.e(t)}finally{n.f()}var a,u=r(this._posts.keys());try{for(u.s();!(a=u.n()).done;){var c=a.value;e._posts.set(c,this._posts.get(c).slice())}}catch(t){u.e(t)}finally{u.f()}return e},i.prototype.merge=function(t,e){var n,o=(e=1===arguments.length||e)?this.clone():this,i=r(t._pres.keys());try{var s=function(){var e=n.value,r=a(o._pres,e,[]),i=t._pres.get(e).filter((function(t){return-1===r.map((function(t){return t.fn})).indexOf(t.fn)})),s=r.concat(i);s.numAsync=r.numAsync||0,s.numAsync+=i.filter((function(t){return t.isAsync})).length,o._pres.set(e,s)};for(i.s();!(n=i.n()).done;)s()}catch(t){i.e(t)}finally{i.f()}var u,c=r(t._posts.keys());try{var l=function(){var e=u.value,r=a(o._posts,e,[]),n=t._posts.get(e).filter((function(t){return-1===r.indexOf(t)}));o._posts.set(e,r.concat(n))};for(c.s();!(u=c.n()).done;)l()}catch(t){c.e(t)}finally{c.f()}return o},t.exports=i}).call(this,r(8))},function(t,e,r){"use strict";var n=r(10),o=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,e),null!=e&&null!=e.options&&(this.options=Object.assign({},e.options))};Object.defineProperty(o.prototype,"ref",n),Object.defineProperty(o.prototype,"refPath",n),Object.defineProperty(o.prototype,"localField",n),Object.defineProperty(o.prototype,"foreignField",n),Object.defineProperty(o.prototype,"justOne",n),Object.defineProperty(o.prototype,"count",n),Object.defineProperty(o.prototype,"match",n),Object.defineProperty(o.prototype,"options",n),Object.defineProperty(o.prototype,"skip",n),Object.defineProperty(o.prototype,"limit",n),Object.defineProperty(o.prototype,"perDocumentLimit",n),t.exports=o},function(t,e,r){"use strict";var n=r(3),o=r(21);
|
|
1205
1205
|
/*!
|
|
1206
1206
|
* Gather all indexes defined in the schema, including single nested,
|
|
1207
1207
|
* document arrays, and embedded discriminators.
|
package/index.d.ts
CHANGED
|
@@ -363,11 +363,11 @@ declare module "mongoose" {
|
|
|
363
363
|
getIndexes(): any;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
class Document {
|
|
366
|
+
class Document<T = any> {
|
|
367
367
|
constructor(doc?: any);
|
|
368
368
|
|
|
369
369
|
/** This documents _id. */
|
|
370
|
-
_id?:
|
|
370
|
+
_id?: T;
|
|
371
371
|
|
|
372
372
|
/** This documents __v. */
|
|
373
373
|
__v?: number;
|
|
@@ -456,7 +456,7 @@ declare module "mongoose" {
|
|
|
456
456
|
* document has an `_id`, in which case this function falls back to using
|
|
457
457
|
* `deepEqual()`.
|
|
458
458
|
*/
|
|
459
|
-
equals(doc: Document): boolean;
|
|
459
|
+
equals(doc: Document<T>): boolean;
|
|
460
460
|
|
|
461
461
|
/** Hash containing current validation errors. */
|
|
462
462
|
errors?: Error.ValidationError;
|
|
@@ -642,8 +642,7 @@ declare module "mongoose" {
|
|
|
642
642
|
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#createIndex)
|
|
643
643
|
* function.
|
|
644
644
|
*/
|
|
645
|
-
createIndexes(options: any): Promise<void>;
|
|
646
|
-
createIndexes(options: any, callback?: (err: any) => void): Promise<void>;
|
|
645
|
+
createIndexes(options?: any, callback?: (err: any) => void): Promise<void>;
|
|
647
646
|
|
|
648
647
|
/** Connection the model uses. */
|
|
649
648
|
db: Connection;
|
|
@@ -666,8 +665,7 @@ declare module "mongoose" {
|
|
|
666
665
|
* Sends `createIndex` commands to mongo for each index declared in the schema.
|
|
667
666
|
* The `createIndex` commands are sent in series.
|
|
668
667
|
*/
|
|
669
|
-
ensureIndexes(options: any): Promise<void>;
|
|
670
|
-
ensureIndexes(options: any, callback?: (err: any) => void): Promise<void>;
|
|
668
|
+
ensureIndexes(options?: any, callback?: (err: any) => void): Promise<void>;
|
|
671
669
|
|
|
672
670
|
/**
|
|
673
671
|
* Event emitter that reports any errors that occurred. Useful for global error
|
|
@@ -724,6 +722,8 @@ declare module "mongoose" {
|
|
|
724
722
|
/** Populates document references. */
|
|
725
723
|
populate(docs: Array<any>, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
726
724
|
callback?: (err: any, res: T[]) => void): Promise<Array<T>>;
|
|
725
|
+
populate(doc: any, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
726
|
+
callback?: (err: any, res: T) => void): Promise<T>;
|
|
727
727
|
|
|
728
728
|
/**
|
|
729
729
|
* Makes the indexes in MongoDB match the indexes defined in this model's
|
|
@@ -894,6 +894,8 @@ declare module "mongoose" {
|
|
|
894
894
|
writeConcern?: any;
|
|
895
895
|
}
|
|
896
896
|
|
|
897
|
+
type MongooseQueryOptions = Pick<QueryOptions, "populate" | "lean" | "omitUndefined" | "strict" | "useFindAndModify">;
|
|
898
|
+
|
|
897
899
|
interface SaveOptions {
|
|
898
900
|
checkKeys?: boolean;
|
|
899
901
|
j?: boolean;
|
|
@@ -1444,6 +1446,15 @@ declare module "mongoose" {
|
|
|
1444
1446
|
unique?: boolean
|
|
1445
1447
|
}
|
|
1446
1448
|
|
|
1449
|
+
interface ValidatorProps {
|
|
1450
|
+
path: string;
|
|
1451
|
+
value: any;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
interface ValidatorMessageFn {
|
|
1455
|
+
(props: ValidatorProps): string;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1447
1458
|
interface ValidateFn<T> {
|
|
1448
1459
|
(value: T): boolean;
|
|
1449
1460
|
}
|
|
@@ -1458,7 +1469,7 @@ declare module "mongoose" {
|
|
|
1458
1469
|
|
|
1459
1470
|
interface ValidateOpts<T> {
|
|
1460
1471
|
msg?: string;
|
|
1461
|
-
message?: string;
|
|
1472
|
+
message?: string | ValidatorMessageFn;
|
|
1462
1473
|
type?: string;
|
|
1463
1474
|
validator: ValidateFn<T> | LegacyAsyncValidateFn<T> | AsyncValidateFn<T>;
|
|
1464
1475
|
}
|
|
@@ -1651,7 +1662,7 @@ declare module "mongoose" {
|
|
|
1651
1662
|
shift(): T;
|
|
1652
1663
|
|
|
1653
1664
|
/** Returns a native js Array. */
|
|
1654
|
-
toObject(options
|
|
1665
|
+
toObject(options?: ToObjectOptions): any;
|
|
1655
1666
|
|
|
1656
1667
|
/** Wraps [`Array#unshift`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/unshift) with proper change tracking. */
|
|
1657
1668
|
unshift(...args: any[]): number;
|
|
@@ -1693,7 +1704,7 @@ declare module "mongoose" {
|
|
|
1693
1704
|
|
|
1694
1705
|
class Map<V> extends global.Map<string, V> {
|
|
1695
1706
|
/** Converts a Mongoose map into a vanilla JavaScript map. */
|
|
1696
|
-
toObject(options
|
|
1707
|
+
toObject(options?: ToObjectOptions & { flattenMaps?: boolean }): any;
|
|
1697
1708
|
}
|
|
1698
1709
|
|
|
1699
1710
|
var ObjectId: ObjectIdConstructor;
|
|
@@ -1723,7 +1734,7 @@ declare module "mongoose" {
|
|
|
1723
1734
|
}
|
|
1724
1735
|
|
|
1725
1736
|
interface Query<ResultType, DocType extends Document> {
|
|
1726
|
-
_mongooseOptions:
|
|
1737
|
+
_mongooseOptions: MongooseQueryOptions;
|
|
1727
1738
|
|
|
1728
1739
|
exec(): Promise<ResultType>;
|
|
1729
1740
|
exec(callback?: (err: CallbackError, res: ResultType) => void): void;
|
|
@@ -1942,7 +1953,7 @@ declare module "mongoose" {
|
|
|
1942
1953
|
* Getter/setter around the current mongoose-specific options for this query
|
|
1943
1954
|
* Below are the current Mongoose-specific options.
|
|
1944
1955
|
*/
|
|
1945
|
-
mongooseOptions(val?:
|
|
1956
|
+
mongooseOptions(val?: MongooseQueryOptions): MongooseQueryOptions;
|
|
1946
1957
|
|
|
1947
1958
|
/** Specifies a `$ne` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
1948
1959
|
ne(val: any): this;
|
|
@@ -2068,7 +2079,7 @@ declare module "mongoose" {
|
|
|
2068
2079
|
then: Promise<ResultType>["then"];
|
|
2069
2080
|
|
|
2070
2081
|
/** Converts this query to a customized, reusable query constructor with all arguments and options retained. */
|
|
2071
|
-
toConstructor(): new (
|
|
2082
|
+
toConstructor(): new (...args: any[]) => Query<ResultType, DocType>;
|
|
2072
2083
|
|
|
2073
2084
|
/** Declare and/or execute this query as an update() operation. */
|
|
2074
2085
|
update(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType>, options?: QueryOptions | null, callback?: (err: CallbackError, res: any) => void): Query<any, DocType>;
|
|
@@ -2125,7 +2136,7 @@ declare module "mongoose" {
|
|
|
2125
2136
|
type _AllowStringsForIds<T> = {
|
|
2126
2137
|
[K in keyof T]: [Extract<T[K], mongodb.ObjectId>] extends [never] ? T[K] : T[K] | string;
|
|
2127
2138
|
};
|
|
2128
|
-
export type DocumentDefinition<T> = _AllowStringsForIds<Omit<T, Exclude<keyof Document, '_id'>>>;
|
|
2139
|
+
export type DocumentDefinition<T> = _AllowStringsForIds<Omit<Omit<T, Exclude<keyof Document, '_id'>>, FunctionPropertyNames<T>>>;
|
|
2129
2140
|
|
|
2130
2141
|
type FunctionPropertyNames<T> = {
|
|
2131
2142
|
// The 1 & T[K] check comes from: https://stackoverflow.com/questions/55541275/typescript-check-for-the-any-type
|
|
@@ -2245,6 +2256,18 @@ declare module "mongoose" {
|
|
|
2245
2256
|
/** Appends new custom $lookup operator to this aggregate pipeline. */
|
|
2246
2257
|
lookup(options: any): this;
|
|
2247
2258
|
|
|
2259
|
+
/**
|
|
2260
|
+
* Appends a new custom $match operator to this aggregate pipeline.
|
|
2261
|
+
* @param arg $match operator contents
|
|
2262
|
+
*/
|
|
2263
|
+
match(arg: any): this;
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* Binds this aggregate to a model.
|
|
2267
|
+
* @param model the model to which the aggregate is to be bound
|
|
2268
|
+
*/
|
|
2269
|
+
model(model: any): this;
|
|
2270
|
+
|
|
2248
2271
|
/** Returns the current pipeline */
|
|
2249
2272
|
pipeline(): any[];
|
|
2250
2273
|
|