mongoose 5.11.13 → 5.11.14
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 +10 -0
- package/dist/browser.umd.js +39 -38
- package/index.d.ts +2 -2
- package/lib/document.js +1 -3
- package/lib/error/validation.js +2 -1
- package/lib/helpers/populate/getModelsMapForPopulate.js +5 -5
- package/lib/helpers/populate/getSchemaTypes.js +0 -7
- package/lib/model.js +0 -6
- package/lib/schema/SingleNestedPath.js +4 -4
- package/lib/schema/array.js +1 -1
- package/lib/schematype.js +1 -3
- package/lib/types/map.js +1 -2
- package/lib/types/subdocument.js +3 -1
- package/package.json +3 -2
package/History.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
5.11.14 / 2021-01-28
|
|
2
|
+
====================
|
|
3
|
+
* fix(populate): avoid inferring `justOne` from parent when populating a POJO with a manually populated path #9833 [IslandRhythms](https://github.com/IslandRhythms)
|
|
4
|
+
* fix(document): apply setters on each element of the array when setting a populated array #9838
|
|
5
|
+
* fix(map): handle change tracking on maps of subdocs #9811 [IslandRhythms](https://github.com/IslandRhythms)
|
|
6
|
+
* fix(document): remove dependency on `documentIsSelected` symbol #9841 [IslandRhythms](https://github.com/IslandRhythms)
|
|
7
|
+
* fix(error): make ValidationError.toJSON to include the error name correctly #9849 [hanzki](https://github.com/hanzki)
|
|
8
|
+
* fix(index.d.ts): indicate that `Document#remove()` returns a promise, not a query #9826
|
|
9
|
+
* fix(index.d.ts): allow setting `SchemaType#enum` to TypeScript enum with `required: true` #9546
|
|
10
|
+
|
|
1
11
|
5.11.13 / 2021-01-20
|
|
2
12
|
====================
|
|
3
13
|
* fix(map): handle change tracking on map of arrays #9813
|
package/dist/browser.umd.js
CHANGED
|
@@ -235,22 +235,22 @@ e.noop=function(){}}).call(this,r(8))},function(t,e,r){"use strict";
|
|
|
235
235
|
/*!
|
|
236
236
|
* Module dependencies.
|
|
237
237
|
*/
|
|
238
|
-
function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(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 s(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 s(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,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,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function s(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 a(t){return(a="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 u,c,l,f=r(19).EventEmitter,p=r(109),h=r(5),y=r(25),d=r(73),_=r(135),m=r(136),v=r(52),g=r(32),b=r(31),w=r(71),O=r(53),S=r(24),A=r(84),E=r(57).compile,j=r(57).defineKey,$=r(172).flatten,P=r(3),x=r(173),N=r(88),T=r(174),k=r(58),C=r(175),R=r(4).inspect,D=r(17).internalToObjectOptions,B=r(46),M=r(176),I=r(2),F=r(178),L=I.clone,U=I.deepEqual,V=I.isMongooseObject,q=Symbol("mongoose.Array#atomicsBackup"),W=r(0).arrayAtomicsSymbol,H=r(0).documentArrayParent,Y=r(0).
|
|
238
|
+
function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(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 s(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 s(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,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,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function s(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 a(t){return(a="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 u,c,l,f=r(19).EventEmitter,p=r(109),h=r(5),y=r(25),d=r(73),_=r(135),m=r(136),v=r(52),g=r(32),b=r(31),w=r(71),O=r(53),S=r(24),A=r(84),E=r(57).compile,j=r(57).defineKey,$=r(172).flatten,P=r(3),x=r(173),N=r(88),T=r(174),k=r(58),C=r(175),R=r(4).inspect,D=r(17).internalToObjectOptions,B=r(46),M=r(176),I=r(2),F=r(178),L=I.clone,U=I.deepEqual,V=I.isMongooseObject,q=Symbol("mongoose.Array#atomicsBackup"),W=r(0).arrayAtomicsSymbol,H=r(0).documentArrayParent,Y=r(0).documentIsModified,K=r(0).documentModifiedPaths,z=r(0).documentSchemaSymbol,Q=r(0).getSymbol,J=r(0).populateModelSymbol,G=r(0).scopeSymbol,X=I.specialProperties;function Z(t,e,r,n){var o=this;"object"===a(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n);var s=P(n,"defaults",!0);if(n.defaults=s,null==this.schema){var u=I.isObject(e)&&!e.instanceOfSchema?new v(e):e;this.$__setSchema(u),e=r,r=n,n=arguments[4]||{}}if(this.$__=new p,this.$__.emitter=new f,this.isNew=!("isNew"in n)||n.isNew,this.errors=void 0,this.$__.$options=n||{},this.$locals={},this.$op=null,null!=t&&"object"!==a(t))throw new _(t,"obj","Document");var c=this.schema;"boolean"==typeof e||"throw"===e?(this.$__.strictMode=e,e=void 0):(this.$__.strictMode=c.options.strict,this.$__.selected=e);var l,h=c.requiredPaths(!0),y=i(h);try{for(y.s();!(l=y.n()).done;){var d=l.value;this.$__.activePaths.require(d)}}catch(t){y.e(t)}finally{y.f()}this.$__.emitter.setMaxListeners(0);var m=null;I.isPOJO(e)&&(m=C(e));var g=!1===m&&e?et(e):{};if(null==this._doc&&(this.$__buildDoc(t,e,r,m,g,!1),s&&rt(this,e,r,m,g,!0,{isNew:this.isNew})),t&&(this.$__original_set?this.$__original_set(t,void 0,!0):this.$set(t,void 0,!0),t instanceof Z&&(this.isNew=t.isNew)),n.willInit&&s?f.prototype.once.call(this,"init",(function(){rt(o,e,r,m,g,!1,n.skipDefaults,o.isNew)})):s&&rt(this,e,r,m,g,!1,n.skipDefaults,this.isNew),this.$__._id=this._id,!this.$__.strictMode&&t){var b=this,w=Object.keys(this._doc);w.forEach((function(t){t in c.tree||j(t,null,b)}))}st(this)}
|
|
239
239
|
/*!
|
|
240
240
|
* Document exposes the NodeJS event emitter API, so you can use
|
|
241
241
|
* `on`, `once`, etc.
|
|
242
|
-
*/for(var
|
|
242
|
+
*/for(var tt in I.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],(function(t){Z.prototype[t]=function(){return this.$__.emitter[t].apply(this.$__.emitter,arguments)}})),Z.prototype.constructor=Z,f.prototype)Z[tt]=f.prototype[tt];
|
|
243
243
|
/*!
|
|
244
244
|
* ignore
|
|
245
245
|
*/
|
|
246
|
-
function
|
|
246
|
+
function et(t){for(var e={},r=0,n=Object.keys(t);r<n.length;r++){var o,s=[],a=i(n[r].split("."));try{for(a.s();!(o=a.n()).done;){var u=o.value;s.push(u),e[s.join(".")]=1}}catch(t){a.e(t)}finally{a.f()}}return e}
|
|
247
247
|
/*!
|
|
248
248
|
* ignore
|
|
249
|
-
*/function
|
|
249
|
+
*/function rt(t,e,r,n,o,i,s){for(var a=Object.keys(t.schema.paths),u=a.length,c=0;c<u;++c){var l=void 0,f="",p=a[c];if("_id"!==p||!r)for(var h=t.schema.paths[p],y=-1===p.indexOf(".")?[p]:p.split("."),d=y.length,_=!1,m=t._doc,v=0;v<d&&null!=m;++v){var g=y[v];if(f+=(f.length?".":"")+g,!0===n){if(f in e)break}else if(!1===n&&e&&!_)if(f in e)_=!0;else if(!o[f])break;if(v===d-1){if(void 0!==m[g])break;if("function"==typeof h.defaultValue){if(!h.defaultValue.$runBeforeSetters&&i)break;if(h.defaultValue.$runBeforeSetters&&!i)break}else if(!i)continue;if(s&&s[f])break;if(e&&null!==n){if(!0===n){if(p in e)continue;try{l=h.getDefault(t,!1)}catch(e){t.invalidate(p,e);break}void 0!==l&&(m[g]=l,t.$__.activePaths.default(p))}else if(_){try{l=h.getDefault(t,!1)}catch(e){t.invalidate(p,e);break}void 0!==l&&(m[g]=l,t.$__.activePaths.default(p))}}else{try{l=h.getDefault(t,!1)}catch(e){t.invalidate(p,e);break}void 0!==l&&(m[g]=l,t.$__.activePaths.default(p))}}else m=m[g]}}}function nt(t){if(null==t)return!0;if("object"!==a(t)||Array.isArray(t))return!1;for(var e=0,r=Object.keys(t);e<r.length;e++){if(!nt(t[r[e]]))return!1}return!0}
|
|
250
250
|
/*!
|
|
251
251
|
* ignore
|
|
252
252
|
*/
|
|
253
|
-
function
|
|
253
|
+
function ot(t){var e={};!
|
|
254
254
|
/*!
|
|
255
255
|
* ignore
|
|
256
256
|
*/
|
|
@@ -261,36 +261,36 @@ function(t){Object.keys(t.$__.activePaths.states.require).forEach((function(e){v
|
|
|
261
261
|
/*!
|
|
262
262
|
* ignore
|
|
263
263
|
*/
|
|
264
|
-
function
|
|
264
|
+
function it(t,e){var r,n=new Set(e),o=new Map([]),s=i(e);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(-1!==a.indexOf("."))for(var u=a.split("."),c=u[0],l=1;l<u.length;++l)o.set(c,a),c=c+"."+u[l]}}catch(t){s.e(t)}finally{s.f()}var f,p=[],h=i(t);try{for(h.s();!(f=h.n()).done;){var y=f.value;n.has(y)?p.push(y):o.has(y)&&p.push(o.get(y))}}catch(t){h.e(t)}finally{h.f()}return p}
|
|
265
265
|
/*!
|
|
266
266
|
* Runs queued functions
|
|
267
267
|
*/
|
|
268
|
-
function
|
|
268
|
+
function st(t){var e=t.schema&&t.schema.callQueue;if(e.length){var r,n=i(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;"pre"!==o[0]&&"post"!==o[0]&&"on"!==o[0]&&t[o[0]].apply(t,o[1])}}catch(t){n.e(t)}finally{n.f()}}}
|
|
269
269
|
/*!
|
|
270
270
|
* ignore
|
|
271
271
|
*/
|
|
272
272
|
/*!
|
|
273
273
|
* Applies virtuals properties to `json`.
|
|
274
274
|
*/
|
|
275
|
-
function
|
|
275
|
+
function at(t,e,r,n){var o,i,s,a=t.schema,u=Object.keys(a.virtuals),c=u.length,l=c,f=t._doc,p=P(n,"aliases",!0);if(!f)return e;for(r=r||{},c=0;c<l;++c)if(o=u[c],p||!a.aliases.hasOwnProperty(o)){if(i=o,null!=r.path){if(!o.startsWith(r.path+"."))continue;i=o.substr(r.path.length+1)}var h=i.split(".");if(void 0!==(s=L(t.get(o),r))){var y=h.length;f=e;for(var d=0;d<y-1;++d)f[h[d]]=f[h[d]]||{},f=f[h[d]];f[h[y-1]]=s}}return e}
|
|
276
276
|
/*!
|
|
277
277
|
* Applies virtuals properties to `json`.
|
|
278
278
|
*
|
|
279
279
|
* @param {Document} self
|
|
280
280
|
* @param {Object} json
|
|
281
281
|
* @return {Object} `json`
|
|
282
|
-
*/function
|
|
282
|
+
*/function ut(t,e){if(F(e))throw new Error("`transform` function must be synchronous, but the transform on path `"+t+"` returned a promise.")}
|
|
283
283
|
/*!
|
|
284
284
|
* ignore
|
|
285
|
-
*/
|
|
285
|
+
*/Z.prototype.schema,Object.defineProperty(Z.prototype,"$locals",{configurable:!1,enumerable:!1,writable:!0}),Z.prototype.isNew,Z.prototype.id,Z.prototype.errors,Z.prototype.$op,Z.prototype.$__buildDoc=function(t,e,r,n,o){for(var i={},s=Object.keys(this.schema.paths).filter((function(t){return!t.includes("$*")})),a=s.length,u=0;u<a;++u){var c=s[u];if("_id"===c){if(r)continue;if(t&&"_id"in t)continue}for(var l=c.split("."),f=l.length,p=f-1,h="",y=i,d=!1,_=0;_<f;++_){var m=l[_];if(h+=(h.length?".":"")+m,!0===n){if(h in e)break}else if(!1===n&&e&&!d)if(h in e)d=!0;else if(!o[h])break;_<p&&(y=y[m]||(y[m]={}))}}this._doc=i},
|
|
286
286
|
/*!
|
|
287
287
|
* Converts to POJO when you use the document for querying
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
Z.prototype.toBSON=function(){return this.toObject(D)},Z.prototype.init=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.$__init(t,e),r&&r(null,this),this},
|
|
290
290
|
/*!
|
|
291
291
|
* ignore
|
|
292
292
|
*/
|
|
293
|
-
|
|
293
|
+
Z.prototype.$__init=function(t,e){if(this.isNew=!1,this.$init=!0,e=e||{},null!=t._id&&e.populated&&e.populated.length){var r,n=String(t._id),o=i(e.populated);try{for(o.s();!(r=o.n()).done;){var s=r.value;if(s.isVirtual?this.populated(s.path,I.getValue(s.path,t),s):this.populated(s.path,s._docs[n],s),null!=s._childDocs){var a,u=i(s._childDocs);try{for(u.s();!(a=u.n()).done;){var c=a.value;null!=c&&null!=c.$__&&(c.$__.parent=this)}}catch(t){u.e(t)}finally{u.f()}}}}catch(t){o.e(t)}finally{o.f()}}
|
|
294
294
|
/*!
|
|
295
295
|
* Init helper.
|
|
296
296
|
*
|
|
@@ -308,26 +308,26 @@ return function t(e,r,n,o,i){i=i||"";var s,a,u,c=Object.keys(r),l=c.length,f=0;f
|
|
|
308
308
|
* const doc = await Article.findOne().populate('comments.author');
|
|
309
309
|
* doc.comments[0].populated('author'); // Should be set
|
|
310
310
|
*/
|
|
311
|
-
function(t,e){if(null==t._id||null==e||0===e.length)return;var r,n=String(t._id),o=i(e);try{for(o.s();!(r=o.n()).done;){var s=r.value;if(!s.isVirtual)for(var a=s.path.split("."),u=0;u<a.length-1;++u){var c=a.slice(0,u+1).join("."),l=a.slice(u+1).join("."),f=t.get(c);if(null!=f&&f.isMongooseDocumentArray){for(var p=0;p<f.length;++p)f[p].populated(l,null==s._docs[n]?[]:s._docs[n][p],s);break}}}}catch(t){o.e(t)}finally{o.f()}}(this,e.populated),this.emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},
|
|
311
|
+
function(t,e){if(null==t._id||null==e||0===e.length)return;var r,n=String(t._id),o=i(e);try{for(o.s();!(r=o.n()).done;){var s=r.value;if(!s.isVirtual)for(var a=s.path.split("."),u=0;u<a.length-1;++u){var c=a.slice(0,u+1).join("."),l=a.slice(u+1).join("."),f=t.get(c);if(null!=f&&f.isMongooseDocumentArray){for(var p=0;p<f.length;++p)f[p].populated(l,null==s._docs[n]?[]:s._docs[n][p],s);break}}}}catch(t){o.e(t)}finally{o.f()}}(this,e.populated),this.emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},Z.prototype.update=function(){var t=I.args(arguments);t.unshift({_id:this._id});var e=this.constructor.update.apply(this.constructor,t);return null!=this.$session()&&("session"in e.options||(e.options.session=this.$session())),e},Z.prototype.updateOne=function(t,e,r){var n=this,o=this.constructor.updateOne({_id:this._id},t,e);return o._pre((function(t){n.constructor._middleware.execPre("updateOne",n,[n],t)})),o._post((function(t){n.constructor._middleware.execPost("updateOne",n,[n],{},t)})),null!=this.$session()&&("session"in o.options||(o.options.session=this.$session())),null!=r?o.exec(r):o},Z.prototype.replaceOne=function(){var t=I.args(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},Z.prototype.$session=function(t){if(0===arguments.length)return this.$__.session;if(this.$__.session=t,!this.ownerDocument){var e,r=this.$__getAllSubdocs(),n=i(r);try{for(n.s();!(e=n.n()).done;){var o=e.value;o.$session(t)}}catch(t){n.e(t)}finally{n.f()}}return t},Z.prototype.overwrite=function(t){for(var e=0,r=Array.from(new Set(Object.keys(this._doc).concat(Object.keys(t))));e<r.length;e++){var n=r[e];"_id"!==n&&(this.schema.options.versionKey&&n===this.schema.options.versionKey||this.schema.options.discriminatorKey&&n===this.schema.options.discriminatorKey||this.$set(n,t[n]))}return this},Z.prototype.$set=function(t,e,r,n){var s=this;I.isPOJO(r)&&(n=r,r=void 0);var u,c,l,f,p=(n=n||{}).merge,_=r&&!0!==r,m=!0===r,v=0,b="strict"in n?n.strict:this.$__.strictMode;if(_&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.schema.interpretAsType(t,r,this.schema.options)),null==t){var w=t;t=e,e=w}else{if("string"!=typeof t){t instanceof Z&&(t=t.$__isNested?t.toObject():t._doc),f=e?e+".":"";var O=(u=Object.keys(t)).length,S=P(n,"_skipMinimizeTopLevel",!1);if(0===O&&S)return delete n._skipMinimizeTopLevel,e&&this.$set(e,{}),this;for(var E=0;E<O;++E){var j=f+(l=u[E]);if(c=this.schema.pathType(j),!0!==r||f||null==t[l]||"nested"!==c||null==this._doc[l]||0!==Object.keys(this._doc[l]).length||(delete this._doc[l],n=Object.assign({},n,{_skipMinimizeTopLevel:!0})),!("object"!==a(t[l])||I.isNativeObject(t[l])||I.isMongooseType(t[l])||null==t[l]||"virtual"===c||"real"===c||"adhocOrUndefined"===c||this.$__path(j)instanceof y||this.schema.paths[j]&&this.schema.paths[j].options&&this.schema.paths[j].options.ref))this.$__.$setCalled.add(f+l),this.$set(t[l],f+l,m,n);else if(b){if(m&&void 0===t[l]&&void 0!==this.get(j))continue;if("adhocOrUndefined"===c&&(c=x(this,j,{typeOnly:!0})),"real"===c||"virtual"===c){var $=t[l];this.schema.paths[j]&&this.schema.paths[j].$isSingleNested&&t[l]instanceof Z&&($=$.toObject({virtuals:!1,transform:!1})),this.$set(f+l,$,m,n)}else if("nested"===c&&t[l]instanceof Z)this.$set(f+l,t[l].toObject({transform:!1}),m,n);else if("throw"===b)throw"nested"===c?new d(l,t[l]):new g(l)}else void 0!==t[l]&&this.$set(f+l,t[l],m,n)}return this}this.$__.$setCalled.add(t)}var T,k=this.schema.pathType(t);if("adhocOrUndefined"===k&&(k=x(this,t,{typeOnly:!0})),e=N(e),"nested"===k&&e){if("object"===a(e)&&null!=e){var C=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.isNew&&!this.$__.savedState.hasOwnProperty(t)){var R=this.$__getValue(t);this.$__.savedState[t]=R;for(var D=0,M=Object.keys(R||{});D<M.length;D++){var F=M[D];this.$__.savedState[t+"."+F]=R[F]}}if(p)return this.$set(e,t,m);this.$__setValue(t,null),A(this,t);var L=Object.keys(e);this.$__setValue(t,{});for(var U=0,V=L;U<V.length;U++){var q=V[U];this.$set(t+"."+q,e[q],m)}return C&&I.deepEqual(this.$__.savedState[t],e)?this.unmarkModified(t):this.markModified(t),A(this,t,{skipDocArrays:!0}),this}return this.invalidate(t,new h.CastError("Object",e,t)),this}var W=-1===t.indexOf(".")?[t]:t.split(".");if("string"==typeof this.schema.aliases[W[0]]&&(W[0]=this.schema.aliases[W[0]]),"adhocOrUndefined"===k&&b){var H;for(v=0;v<W.length;++v){var Y=W.slice(0,v+1).join(".");if(v+1<W.length&&"virtual"===this.schema.pathType(Y))return B.set(t,e,this),this;if(null!=(T=this.schema.path(Y))&&T instanceof y){H=!0;break}}if(null==T&&(T=x(this,t)),!H&&!T){if("throw"===b)throw new g(t);return this}}else{if("virtual"===k)return(T=this.schema.virtualpath(t)).applySetters(e,this),this;T=this.$__path(t)}var K,z=this._doc,Q="";for(v=0;v<W.length-1;++v)z=z[W[v]],Q+=(Q.length>0?".":"")+W[v],z||(this.$set(Q,{}),this.isSelected(Q)||this.unmarkModified(Q),z=this.$__getValue(Q));if(W.length<=1)K=t;else{for(v=0;v<W.length;++v){var G=W.slice(0,v+1).join(".");if(null===this.get(G,null,{getters:!1})){K=G;break}}K||(K=t)}var X=null!=s.$__.$options.priorDoc?s.$__.$options.priorDoc.$__getValue(t):m?void 0:s.$__getValue(t);if(!T)return this.$__set(K,t,m,W,T,e,X),this;if((T.$isSingleNested||T.$isMongooseArray)&&
|
|
312
312
|
/*!
|
|
313
313
|
* ignore
|
|
314
314
|
*/
|
|
315
315
|
function(t,e){if(!t.$__.validationError)return;for(var r=Object.keys(t.$__.validationError.errors),n=0,o=r;n<o.length;n++){var i=o[n];i.startsWith(e+".")&&delete t.$__.validationError.errors[i]}0===Object.keys(t.$__.validationError.errors).length&&(t.$__.validationError=null)}
|
|
316
316
|
/*!
|
|
317
317
|
* ignore
|
|
318
|
-
*/(this,t),T.$isSingleNested&&null!=e&&p){e instanceof
|
|
318
|
+
*/(this,t),T.$isSingleNested&&null!=e&&p){e instanceof Z&&(e=e.toObject({virtuals:!1,transform:!1}));for(var tt=0,et=Object.keys(e);tt<et.length;tt++){var rt=et[tt];this.$set(t+"."+rt,e[rt],m,n)}return this}var nt=!0;try{var ot,it=function(){if(null==T.options)return!1;if(!(e instanceof Z))return!1;var t=e.constructor,r=T.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=T.options.refPath;if(null==n)return!1;var o=e.get(n);return o===t.modelName||o===t.baseModelName}(),st=!1;if(it&&e instanceof Z&&(this.populated(t,e._id,o({},J,e.constructor)),e.$__.wasPopulated=!0,st=!0),T.options&&Array.isArray(T.options[this.schema.options.typeKey])&&T.options[this.schema.options.typeKey].length&&T.options[this.schema.options.typeKey][0].ref&&
|
|
319
319
|
/*!
|
|
320
320
|
* ignore
|
|
321
321
|
*/
|
|
322
|
-
function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=i(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(!(o instanceof
|
|
322
|
+
function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=i(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(!(o instanceof Z))return!1;if(null==o.constructor.modelName)return!1;if(o.constructor.modelName!=e&&o.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,T.options[this.schema.options.typeKey][0].ref)){this.ownerDocument?(ot=o({},J,e[0].constructor),this.ownerDocument().populated(this.$__fullPath(t),e.map((function(t){return t._id})),ot)):(ot=o({},J,e[0].constructor),this.populated(t,e.map((function(t){return t._id})),ot));var at,ut=i(e);try{for(ut.s();!(at=ut.n()).done;){at.value.$__.wasPopulated=!0}}catch(t){ut.e(t)}finally{ut.f()}st=!0}if(null==this.schema.singleNestedPaths[t]&&(e=T.applySetters(e,this,!1,X)),T.$isMongooseDocumentArray&&Array.isArray(e)&&e.length>0&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var ct=Object.keys(e[0].$__.populated),lt=function(){var r=pt[ft];s.populated(t+"."+r,e.map((function(t){return t.populated(r)})),e[0].$__.populated[r].options)},ft=0,pt=ct;ft<pt.length;ft++)lt();st=!0}if(!st&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var ht=0;ht<e.length;++ht)e[ht]instanceof Z&&(e[ht]=e[ht]._id);delete this.$__.populated[t]}T.$isSingleNested&&null!=e&&function(t,e,r){var n=e.schema;if(null==n)return;for(var o=0,i=Object.keys(n.paths);o<i.length;o++){var s=i[o],a=n.paths[s];if(null!=a.$immutableSetter){var u=null==r?void 0:r.$__getValue(s);a.$immutableSetter.call(t,u)}}}(e,T,X),this.$markValid(t)}catch(r){r instanceof h.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof h.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new h.CastError(T.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new h.CastError(T.instance,e,t,r)),nt=!1}return nt&&(this.$__set(K,t,m,W,T,e,X),null!=this.$__.savedState&&(this.isNew||this.$__.savedState.hasOwnProperty(t)?this.$__.savedState.hasOwnProperty(t)&&I.deepEqual(e,this.$__.savedState[t])&&this.unmarkModified(t):this.$__.savedState[t]=X)),T.$isSingleNested&&(this.isDirectModified(t)||null==e)&&A(this,t),this},Z.prototype.set=Z.prototype.$set,Z.prototype.$__shouldModify=function(t,e,r,n,o,i,s){return!!this.isNew||null==this.schema.singleNestedPaths[e]&&(void 0===i&&!this.isSelected(e)||(void 0!==i||!(e in this.$__.activePaths.states.default))&&(!(this.populated(e)&&i instanceof Z&&U(i._id,s))&&(!U(i,s||I.getValue(e,this))||!(r||null==i||!(e in this.$__.activePaths.states.default)||!U(i,o.getDefault(this,r))))))},Z.prototype.$__set=function(t,e,n,o,i,s,a){l=l||r(26);var u=this.$__shouldModify(t,e,n,o,i,s,a),f=this;u&&(this.markModified(t),c||(c=r(82)),s&&s.isMongooseArray&&(s._registerAtomic("$set",s),s.isMongooseDocumentArray&&s.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=s)})),this.$__.activePaths.forEach((function(t){t.startsWith(e+".")&&f.$__.activePaths.ignore(t)}))));for(var p=this._doc,h=0,y=o.length,d="";h<y;h++){var _=h+1===y;if(d+=d?"."+o[h]:o[h],X.has(o[h]))return;_?p instanceof Map?p.set(o[h],s):p[o[h]]=s:(I.isPOJO(p[o[h]])||p[o[h]]&&p[o[h]]instanceof l||p[o[h]]&&p[o[h]].$isSingleNested||p[o[h]]&&Array.isArray(p[o[h]])||(p[o[h]]=p[o[h]]||{}),p=p[o[h]])}},Z.prototype.$__getValue=function(t){return I.getValue(t,this._doc)},Z.prototype.$__setValue=function(t,e){return I.setValue(t,e,this._doc),this},Z.prototype.get=function(t,e,r){var n;r=r||{},e&&(n=this.schema.interpretAsType(t,e,this.schema.options));var o=this.$__path(t);if(null==o&&(o=this.schema.virtualpath(t)),o instanceof y){var i=this.schema.virtualpath(t);null!=i&&(o=i)}var s=t.split("."),a=this._doc;if(o instanceof O)return o.applyGetters(void 0,this);"string"==typeof this.schema.aliases[s[0]]&&(s[0]=this.schema.aliases[s[0]]);for(var u=0,c=s.length;u<c;u++)a&&a._doc&&(a=a._doc),a=null==a?void 0:a instanceof Map?a.get(s[u],{getters:!1}):u===c-1?I.getValue(s[u],a):a[s[u]];if(n&&(a=n.cast(a)),null!=o&&!1!==r.getters)a=o.applyGetters(a,this);else if(this.schema.nested[t]&&r.virtuals)return at(this,I.clone(a)||{},{path:t});return a},
|
|
323
323
|
/*!
|
|
324
324
|
* ignore
|
|
325
325
|
*/
|
|
326
|
-
|
|
326
|
+
Z.prototype[Q]=Z.prototype.get,Z.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e.hasOwnProperty(t)?e[t]:null;return r||this.schema.path(t)},Z.prototype.markModified=function(t,e){this.$__.activePaths.modify(t),null==e||this.ownerDocument||(this.$__.pathsToScopes[t]=e)},Z.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),delete this.$__.pathsToScopes[t]},Z.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},Z.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.states.modify)},Z.prototype.$isEmpty=function(t){var e={minimize:!0,virtuals:!1,getters:!1,transform:!1};if(arguments.length>0){var r=this.get(t);return null==r||"object"===a(r)&&(I.isPOJO(r)?nt(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},Z.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.states.modify),r=this;return e.reduce((function(e,n){var o=n.split(".");if(e=e.concat(o.reduce((function(t,e,r){return t.concat(o.slice(0,r).concat(e).join("."))}),[]).filter((function(t){return-1===e.indexOf(t)}))),!t.includeChildren)return e;var s=r.get(n);if(null!=s&&"object"===a(s))if(s._doc&&(s=s._doc),Array.isArray(s)){for(var u=s.length,c=0;c<u;++c)if(-1===e.indexOf(n+"."+c)&&(e.push(n+"."+c),null!=s[c]&&s[c].$__)){var l,f=i(s[c].modifiedPaths());try{for(f.s();!(l=f.n()).done;){var p=l.value;e.push(n+"."+c+"."+p)}}catch(t){f.e(t)}finally{f.f()}}}else Object.keys(s).filter((function(t){return-1===e.indexOf(n+"."+t)})).forEach((function(t){e.push(n+"."+t)}));return e}),[])},Z.prototype[K]=Z.prototype.modifiedPaths,Z.prototype.isModified=function(t,e){if(t){Array.isArray(t)||(t=t.split(" "));var r=e||this[K](),n=Object.keys(this.$__.activePaths.states.modify);return t.some((function(t){return!!~r.indexOf(t)}))||t.some((function(t){return n.some((function(e){return e===t||t.startsWith(e+".")}))}))}return this.$__.activePaths.some("modify")},Z.prototype[Y]=Z.prototype.isModified,Z.prototype.$isDefault=function(t){var e=this;if(null==t)return this.$__.activePaths.some("default");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.default.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.default.hasOwnProperty(t)}))},Z.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},Z.prototype.isDirectModified=function(t){var e=this;if(null==t)return this.$__.activePaths.some("modify");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.modify.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.modify.hasOwnProperty(t)}))},Z.prototype.isInit=function(t){var e=this;if(null==t)return this.$__.activePaths.some("init");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.init.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.init.hasOwnProperty(t)}))},Z.prototype.isSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.isSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var o=0,i=r;o<i.length;o++){var s=i[o];if("_id"!==s&&k(this.$__.selected[s])){n=!!this.$__.selected[s];break}}if(null===n)return!0;if(t in this.$__.selected)return n;for(var a=t+".",u=0,c=r;u<c.length;u++){var l=c[u];if("_id"!==l){if(l.startsWith(a))return n||l!==a;if(a.startsWith(l+"."))return n}}return!n},Z.prototype.$__isSelected=Z.prototype.isSelected,Z.prototype.isDirectSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.isDirectSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var o=0,i=r;o<i.length;o++){var s=i[o];if("_id"!==s&&k(this.$__.selected[s])){n=!!this.$__.selected[s];break}}return null===n||(this.$__.selected.hasOwnProperty(t)?n:!n)},Z.prototype.validate=function(t,e,r){var n,o=this;return this.$op="validate",null!=this.ownerDocument||(this.$__.validating?n=new m(this,{parentStack:e&&e.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new m(this,{parentStack:e&&e.parentStack})),"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=t,t=null),S(r,(function(r){if(null!=n)return r(n);o.$__validate(t,e,(function(t){o.$op=null,r(t)}))}),this.constructor.events)},Z.prototype.$__validate=function(t,r,n){var o=this;"function"==typeof t?(n=t,r=null,t=null):"function"==typeof r&&(n=r,r=null);var i,s=r&&"object"===a(r)&&"validateModifiedOnly"in r;i=s?!!r.validateModifiedOnly:this.schema.options.validateModifiedOnly;var u=this,c=function(){var t=o.$__.validationError;if(o.$__.validationError=void 0,i&&null!=t){for(var e=0,r=Object.keys(t.errors);e<r.length;e++){var n=r[e];o.isModified(n)||delete t.errors[n]}0===Object.keys(t.errors).length&&(t=void 0)}if(o.$__.cachedRequired={},o.emit("validate",u),o.constructor.emit("validate",u),o.$__.validating=null,t){for(var s in t.errors)!o[H]&&t.errors[s]instanceof h.CastError&&o.invalidate(s,t.errors[s]);return t}},l=ot(this),f=i?l[0].filter((function(t){return o.isModified(t)})):l[0],p=l[1];if(Array.isArray(t)&&(f=it(f,t)),0===f.length)return e.nextTick((function(){var t=c();if(t)return u.schema.s.hooks.execPost("validate:error",u,[u],{error:t},(function(t){n(t)}));n(null,u)}));for(var y={},d=0,_=function(){var t=c();if(t)return u.schema.s.hooks.execPost("validate:error",u,[u],{error:t},(function(t){n(t)}));n(null,u)},m=function(t){null==t||y[t]||(y[t]=!0,d++,e.nextTick((function(){var e=u.schema.path(t);if(!e)return--d||_();if(u.$isValid(t)){var r,n=u.$__getValue(t);null==n&&(r=u.populated(t))&&(n=r);var o=t in u.$__.pathsToScopes?u.$__.pathsToScopes[t]:u,i={skipSchemaValidators:p[t],path:t};e.doValidate(n,(function(r){if(r&&(!e.$isMongooseDocumentArray||r.$isArrayValidatorError)){if(e.$isSingleNested&&r instanceof b&&!1===e.schema.options.storeSubdocValidationError)return--d||_();u.invalidate(t,r,void 0,!0)}--d||_()}),o,i)}else--d||_()})))},v=f.length,g=0;g<v;++g)m(f[g])},Z.prototype.validateSync=function(t,e){var r,n=this,o=this;r=e&&"object"===a(e)&&"validateModifiedOnly"in e?!!e.validateModifiedOnly:this.schema.options.validateModifiedOnly,"string"==typeof t&&(t=t.split(" "));var i=ot(this),s=r?i[0].filter((function(t){return n.isModified(t)})):i[0],u=i[1];Array.isArray(t)&&(s=it(s,t));var c={};s.forEach((function(t){if(!c[t]){c[t]=!0;var e=o.schema.path(t);if(e&&o.$isValid(t)){var r=o.$__getValue(t),n=e.doValidateSync(r,o,{skipSchemaValidators:u[t],path:t});if(n&&(!e.$isMongooseDocumentArray||n.$isArrayValidatorError)){if(e.$isSingleNested&&n instanceof b&&!1===e.schema.options.storeSubdocValidationError)return;o.invalidate(t,n,void 0,!0)}}}}));var l=o.$__.validationError;if(o.$__.validationError=void 0,o.emit("validate",o),o.constructor.emit("validate",o),l)for(var f in l.errors)l.errors[f]instanceof h.CastError&&o.invalidate(f,l.errors[f]);return l},Z.prototype.invalidate=function(t,e,r,n){if(this.$__.validationError||(this.$__.validationError=new b(this)),!this.$__.validationError.errors[t])return e&&"string"!=typeof e||(e=new w({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e||this.$__.validationError.addError(t,e),this.$__.validationError},Z.prototype.$markValid=function(t){this.$__.validationError&&this.$__.validationError.errors[t]&&(delete this.$__.validationError.errors[t],0===Object.keys(this.$__.validationError.errors).length&&(this.$__.validationError=null))},Z.prototype.$isValid=function(t){var e=this;return null==this.$__.validationError||0===Object.keys(this.$__.validationError.errors).length||null!=t&&(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t)?t.some((function(t){return null==e.$__.validationError.errors[t]})):null==this.$__.validationError.errors[t])},Z.prototype.$__reset=function(){var t=this;return u||(u=r(18)),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length})).forEach((function(e){for(var r=e.length;r--;){var n=e[r];n&&n.$__reset()}t.$__.activePaths.init(e.$path()),e[q]=e[W],e[W]={}})),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t.$isSingleNested})).forEach((function(e){e.$__reset(),t.$__.activePaths.init(e.$basePath)})),this.$__dirty().forEach((function(t){var e=t.value;e&&e[W]&&(e[q]=e[W],e[W]={})})),this.$__.backup={},this.$__.backup.activePaths={modify:Object.assign({},this.$__.activePaths.states.modify),default:Object.assign({},this.$__.activePaths.states.default)},this.$__.backup.validationError=this.$__.validationError,this.$__.backup.errors=this.errors,this.$__.activePaths.clear("modify"),this.$__.activePaths.clear("default"),this.$__.validationError=void 0,this.errors=void 0,t=this,this.schema.requiredPaths().forEach((function(e){t.$__.activePaths.require(e)})),this},
|
|
327
327
|
/*!
|
|
328
328
|
* ignore
|
|
329
329
|
*/
|
|
330
|
-
|
|
330
|
+
Z.prototype.$__undoReset=function(){if(null!=this.$__.backup&&null!=this.$__.backup.activePaths){this.$__.activePaths.states.modify=this.$__.backup.activePaths.modify,this.$__.activePaths.states.default=this.$__.backup.activePaths.default,this.$__.validationError=this.$__.backup.validationError,this.errors=this.$__.backup.errors;var t,e=i(this.$__dirty());try{for(e.s();!(t=e.n()).done;){var r=t.value.value;r&&r[W]&&r[q]&&(r[W]=r[q])}}catch(t){e.e(t)}finally{e.f()}var n,o=i(this.$__getAllSubdocs());try{for(o.s();!(n=o.n()).done;){n.value.$__undoReset()}}catch(t){o.e(t)}finally{o.f()}}},Z.prototype.$__dirty=function(){var t=this,e=this.$__.activePaths.map("modify",(function(e){return{path:e,value:t.$__getValue(e),schema:t.$__path(e)}}));(e=e.concat(this.$__.activePaths.map("default",(function(e){if("_id"!==e&&null!=t.$__getValue(e))return{path:e,value:t.$__getValue(e),schema:t.$__path(e)}})))).sort((function(t,e){return t.path<e.path?-1:t.path>e.path?1:0}));var r,n,o=[];return e.forEach((function(t){t&&(null==r||0!==t.path.indexOf(r)?(r=t.path+".",o.push(t),n=t):null!=n&&null!=n.value&&null!=n.value[W]&&n.value.hasAtomics()&&(n.value[W]={},n.value[W].$set=n.value))})),n=r=null,o},Z.prototype.$__setSchema=function(t){t.plugin(T,{deduplicate:!0}),E(t.tree,this,void 0,t.options);for(var e=0,r=Object.keys(t.virtuals);e<r.length;e++){var n=r[e];t.virtuals[n]._applyDefaultGetters()}this.schema=t,this[z]=t},Z.prototype.$__getArrayPathsToValidate=function(){return u||(u=r(18)),this.$__.activePaths.map("init","modify",function(t){return this.$__getValue(t)}.bind(this)).filter((function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length})).reduce((function(t,e){return t.concat(e)}),[]).filter((function(t){return t}))},Z.prototype.$__getAllSubdocs=function(){u||(u=r(18)),l=l||r(26);var t=this;return Object.keys(this._doc).reduce((function(e,r){return function t(e,r,n){var o=e;return n&&(o=e instanceof Z&&e[z].paths[n]?e._doc[n]:e[n]),o instanceof l?r.push(o):o instanceof Map?r=Array.from(o.keys()).reduce((function(e,r){return t(o.get(r),e,null)}),r):o&&o.$isSingleNested?(r=Object.keys(o._doc).reduce((function(e,r){return t(o._doc,e,r)}),r)).push(o):o&&o.isMongooseDocumentArray?o.forEach((function(e){e&&e._doc&&(r=Object.keys(e._doc).reduce((function(r,n){return t(e._doc,r,n)}),r),e instanceof l&&r.push(e))})):o instanceof Z&&o.$__isNested&&(r=Object.keys(o).reduce((function(e,r){return t(o,e,r)}),r)),r}(t,e,r)}),[])},Z.prototype.$__handleReject=function(t){this.listeners("error").length?this.emit("error",t):this.constructor.listeners&&this.constructor.listeners("error").length&&this.constructor.emit("error",t)},Z.prototype.$toObject=function(t,e){var r,o={transform:!0,flattenDecimals:!0},i=e?"toJSON":"toObject",s=P(this,"constructor.base.options."+i,{}),a=P(this,"schema.options",{});o=I.options(o,L(s)),o=I.options(o,L(a[i]||{})),(t=I.isPOJO(t)?L(t):{})._calledWithOptions=t._calledWithOptions||L(t),"flattenMaps"in t||(t.flattenMaps=o.flattenMaps),r=null!=t._calledWithOptions.minimize?t.minimize:null!=o.minimize?o.minimize:a.minimize;var u=Object.assign(I.clone(t),{_isNested:!0,json:e,minimize:r});if(I.hasUserDefinedProperty(t,"getters")&&(u.getters=t.getters),I.hasUserDefinedProperty(t,"virtuals")&&(u.virtuals=t.virtuals),(t.depopulate||P(t,"_parentOptions.depopulate",!1))&&t._isNested&&this.$__.wasPopulated)return L(this._id,u);(t=I.options(o,t))._isNested=!0,t.json=e,t.minimize=r,u._parentOptions=t,u._skipSingleNestedGetters=!0;var c=Object.assign({},u);c._skipSingleNestedGetters=!1;var l=t.transform,f=L(this._doc,u)||{};t.getters&&(!function(t,e,r){var n,o,i=t.schema,s=Object.keys(i.paths),a=s.length,u=t._doc;if(!u)return e;for(;a--;){var c=(n=s[a]).split("."),l=c.length,f=l-1,p=e,h=void 0;if(u=t._doc,t.isSelected(n))for(var y=0;y<l;++y){if(h=c[y],o=u[h],y===f){var d=t.get(n);p[h]=L(d,r)}else{if(null==o){h in u&&(p[h]=o);break}p=p[h]||(p[h]={})}u=o}}}
|
|
331
331
|
/*!
|
|
332
332
|
* Applies schema type transforms to `json`.
|
|
333
333
|
*
|
|
@@ -341,30 +341,30 @@ tt.prototype.$__undoReset=function(){if(null!=this.$__.backup&&null!=this.$__.ba
|
|
|
341
341
|
* @param {Object} object to minimize
|
|
342
342
|
* @return {Object}
|
|
343
343
|
*/
|
|
344
|
-
function t(e){var r,o,i,s=Object.keys(e),a=s.length;for(;a--;)o=s[a],i=e[o],I.isObject(i)&&!n.isBuffer(i)&&(e[o]=t(i)),void 0!==e[o]?r=!0:delete e[o];return r?e:void 0}(f)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&
|
|
344
|
+
function t(e){var r,o,i,s=Object.keys(e),a=s.length;for(;a--;)o=s[a],i=e[o],I.isObject(i)&&!n.isBuffer(i)&&(e[o]=t(i)),void 0!==e[o]?r=!0:delete e[o];return r?e:void 0}(f)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&at(this,f,c,t),!1===t.versionKey&&this.schema.options.versionKey&&delete f[this.schema.options.versionKey];var p=t.transform;if(p&&function(t,e){var r=t.schema,n=Object.keys(r.paths||{});if(!t._doc)return e;for(var o=0,i=n;o<i.length;o++){var s=i[o],a=r.paths[s];if("function"==typeof a.options.transform){var u=t.get(s),c=a.options.transform.call(t,u);ut(s,c),I.setValue(s,c,e)}else if(null!=a.$embeddedSchemaType&&"function"==typeof a.$embeddedSchemaType.options.transform){for(var l=[].concat(t.get(s)),f=a.$embeddedSchemaType.options.transform,p=0;p<l.length;++p){var h=f.call(t,l[p]);l[p]=h,ut(s,h)}e[s]=l}}}(this,f),t.useProjection&&function(t,e){var r=t.schema,n=Object.keys(r.paths||{});if(!t._doc)return e;var o=t.$__.selected;void 0===o&&(o={},M.applyPaths(o,r));if(null==o||0===Object.keys(o).length)return e;for(var i=0,s=n;i<s.length;i++){var a=s[i];null==o[a]||o[a]||delete e[a]}}(this,f),!0===p||a.toObject&&p){var h=t.json?a.toJSON:a.toObject;h&&(p="function"==typeof t.transform?t.transform:h.transform)}else t.transform=l;if("function"==typeof p){var y=p(this,f,t);void 0!==y&&(f=y)}return f},Z.prototype.toObject=function(t){return this.$toObject(t)},Z.prototype.toJSON=function(t){return this.$toObject(t,!0)},Z.prototype.parent=function(){return this.$__.parent},Z.prototype.$parent=Z.prototype.parent,Z.prototype.inspect=function(t){var e;I.isPOJO(t)&&((e=t).minimize=!1);var r=this.toObject(e);return null==r?"MongooseDocument { "+r+" }":r},R.custom&&(
|
|
345
345
|
/*!
|
|
346
346
|
* Avoid Node deprecation warning DEP0079
|
|
347
347
|
*/
|
|
348
|
-
|
|
348
|
+
Z.prototype[R.custom]=Z.prototype.inspect),Z.prototype.toString=function(){var t=this.inspect();return"string"==typeof t?t:R(t)},Z.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)},Z.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,o=I.populate.apply(null,r),s=i(o);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},Z.prototype.execPopulate=function(t){var e=this,r=null!=t&&"function"!=typeof t;return r?this.populate.apply(this,arguments).execPopulate():S(t,(function(t){e.populate(t)}),this.constructor.events)},Z.prototype.populated=function(t,e,r){if(null==e){if(!this.$__.populated)return;var n=this.$__.populated[t];return n?n.value:void 0}if(!0===e){if(!this.$__.populated)return;return this.$__.populated[t]}this.$__.populated||(this.$__.populated={}),this.$__.populated[t]={value:e,options:r};for(var o=t.split("."),i=0;i<o.length-1;++i){var s=o.slice(0,i+1).join("."),a=this.get(s);if(null!=a&&null!=a.$__&&this.populated(s)){var u=o.slice(i+1).join(".");a.populated(u,e,r);break}}return e},Z.prototype.depopulate=function(t){var e;"string"==typeof t&&(t=t.split(" "));var r=this.$$populatedVirtuals?Object.keys(this.$$populatedVirtuals):[],n=P(this,"$__.populated",{});if(0===arguments.length){var o,s=i(r);try{for(s.s();!(o=s.n()).done;){var a=o.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],this.$set(f,e))}return this}var p,h=i(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&&this.$set(y,e)}}catch(t){h.e(t)}finally{h.f()}return this},Z.prototype.$__fullPath=function(t){return t||""},Z.prototype.getChanges=function(){var t=this.$__delta();return t?t[1]:{}},
|
|
349
349
|
/*!
|
|
350
350
|
* Module exports.
|
|
351
351
|
*/
|
|
352
|
-
|
|
352
|
+
Z.ValidationError=b,t.exports=Z}).call(this,r(8),r(1).Buffer)},function(t,e,r){"use strict";(function(n){
|
|
353
353
|
/*!
|
|
354
354
|
* Module dependencies.
|
|
355
355
|
*/
|
|
356
|
-
function o(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 i(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 i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i(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 s(t){return(s="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 a=r(5),u=r(9),c=r(48),l=r(72),f=r(3),p=r(134),h=r(50),y=r(0).schemaTypeSymbol,d=r(4),_=r(2),m=r(0).validatorErrorSymbol,v=r(0).
|
|
356
|
+
function o(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 i(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 i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i(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 s(t){return(s="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 a=r(5),u=r(9),c=r(48),l=r(72),f=r(3),p=r(134),h=r(50),y=r(0).schemaTypeSymbol,d=r(4),_=r(2),m=r(0).validatorErrorSymbol,v=r(0).documentIsModified,g=a.CastError,b=a.ValidatorError;function w(t,e,r){this[y]=!0,this.path=t,this.instance=r,this.validators=[],this.getters=this.constructor.hasOwnProperty("getters")?this.constructor.getters.slice():[],this.setters=[],e=e||{};for(var n=this.constructor.defaultOptions||{},o=0,i=Object.keys(n);o<i.length;o++){var a=i[o];n.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(e[a]=n[a])}null==e.select&&delete e.select;var c=this.OptionsConstructor||u;this.options=new c(e),this._index=null,_.hasUserDefinedProperty(this.options,"immutable")&&(this.$immutable=this.options.immutable,p(this));for(var l=0,f=Object.keys(this.options);l<f.length;l++){var h=f[l];if("cast"!==h){if(_.hasUserDefinedProperty(this.options,h)&&"function"==typeof this[h]){if("index"===h&&this._index){if(!1===e.index){var d=this._index;if("object"===s(d)&&null!=d){if(d.unique)throw new Error('Path "'+this.path+'" may not have `index` set to false and `unique` set to true');if(d.sparse)throw new Error('Path "'+this.path+'" may not have `index` set to false and `sparse` set to true')}this._index=!1}continue}var m=e[h];if("default"===h){this.default(m);continue}var v=Array.isArray(m)?m:[m];this[h].apply(this,v)}}else this.castFunction(this.options[h])}Object.defineProperty(this,"$$context",{enumerable:!1,configurable:!1,writable:!0,value:null})}
|
|
357
357
|
/*!
|
|
358
358
|
* ignore
|
|
359
|
-
*/
|
|
359
|
+
*/w.prototype.OptionsConstructor=u,w.cast=function(t){return 0===arguments.length||(!1===t&&(t=function(t){return t}),this._cast=t),this._cast},w.prototype.castFunction=function(t){return 0===arguments.length||(!1===t&&(t=this.constructor._defaultCaster||function(t){return t}),this._castFunction=t),this._castFunction},w.set=function(t,e){this.hasOwnProperty("defaultOptions")||(this.defaultOptions=Object.assign({},this.defaultOptions)),this.defaultOptions[t]=e},w.get=function(t){this.getters=this.hasOwnProperty("getters")?this.getters:[],this.getters.push(t)},w.prototype.default=function(t){if(1===arguments.length){if(void 0===t)return void(this.defaultValue=void 0);if(null!=t&&t.instanceOfSchema)throw new a("Cannot set default value of path `"+this.path+"` to a mongoose Schema instance.");return this.defaultValue=t,this.defaultValue}return arguments.length>1&&(this.defaultValue=_.args(arguments)),this.defaultValue},w.prototype.index=function(t){return this._index=t,_.expires(this._index),this},w.prototype.unique=function(t){if(!1===this._index){if(!t)return;throw new Error('Path "'+this.path+'" may not have `index` set to false and `unique` set to true')}return null==this._index||!0===this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.unique=t,this},w.prototype.text=function(t){if(!1===this._index){if(!t)return;throw new Error('Path "'+this.path+'" may not have `index` set to false and `text` set to true')}return null===this._index||void 0===this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.text=t,this},w.prototype.sparse=function(t){if(!1===this._index){if(!t)return;throw new Error('Path "'+this.path+'" may not have `index` set to false and `sparse` set to true')}return null==this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.sparse=t,this},w.prototype.immutable=function(t){return this.$immutable=t,p(this),this},w.prototype.transform=function(t){return this.options.transform=t,this},w.prototype.set=function(t){if("function"!=typeof t)throw new TypeError("A setter must be a function.");return this.setters.push(t),this},w.prototype.get=function(t){if("function"!=typeof t)throw new TypeError("A getter must be a function.");return this.getters.push(t),this},w.prototype.validate=function(t,e,r){var n,o,i,u;if("function"==typeof t||t&&"RegExp"===_.getFunctionName(t.constructor))return"function"==typeof e?(n={validator:t,message:e}).type=r||"user defined":e instanceof Object&&!r?((n=_.clone(e)).message||(n.message=n.msg),n.validator=t,n.type=n.type||"user defined"):(null==e&&(e=a.messages.general.default),r||(r="user defined"),n={message:e,type:r,validator:t}),n.isAsync&&O(),this.validators.push(n),this;for(o=0,i=arguments.length;o<i;o++){if(u=arguments[o],!_.isPOJO(u)){var c="Invalid validator. Received ("+s(u)+") "+u+". See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate";throw new Error(c)}this.validate(u.validator,u)}return this};
|
|
360
360
|
/*!
|
|
361
361
|
* ignore
|
|
362
362
|
*/
|
|
363
|
-
var
|
|
363
|
+
var O=d.deprecate((function(){}),"Mongoose: the `isAsync` option for custom validators is deprecated. Make your async validators return a promise instead: https://mongoosejs.com/docs/validation.html#async-custom-validators");
|
|
364
364
|
/*!
|
|
365
365
|
* ignore
|
|
366
366
|
*/
|
|
367
|
-
function
|
|
367
|
+
function S(t){return this.castForQuery(t)}
|
|
368
368
|
/*!
|
|
369
369
|
* ignore
|
|
370
370
|
*/
|
|
@@ -372,42 +372,42 @@ function A(t){return this.castForQuery(t)}
|
|
|
372
372
|
* Just like handleArray, except also allows `[]` because surprisingly
|
|
373
373
|
* `$in: [1, []]` works fine
|
|
374
374
|
*/
|
|
375
|
-
function
|
|
375
|
+
function A(t){var e=this;return Array.isArray(t)?t.map((function(t){return Array.isArray(t)&&0===t.length?t:e.castForQuery(t)})):[this.castForQuery(t)]}
|
|
376
376
|
/*!
|
|
377
377
|
* ignore
|
|
378
|
-
*/
|
|
378
|
+
*/w.prototype.required=function(t,e){var r={};if(arguments.length>0&&null==t)return this.validators=this.validators.filter((function(t){return t.validator!==this.requiredValidator}),this),this.isRequired=!1,delete this.originalRequiredValue,this;if("object"===s(t)&&(e=(r=t).message||e,t=t.isRequired),!1===t)return this.validators=this.validators.filter((function(t){return t.validator!==this.requiredValidator}),this),this.isRequired=!1,delete this.originalRequiredValue,this;var n=this;this.isRequired=!0,this.requiredValidator=function(e){var r=f(this,"$__.cachedRequired");if(null!=r&&!this.$__isSelected(n.path)&&!this[v](n.path))return!0;if(null!=r&&n.path in r){var o=!r[n.path]||n.checkRequired(e,this);return delete r[n.path],o}return"function"==typeof t&&!t.apply(this)||n.checkRequired(e,this)},this.originalRequiredValue=t,"string"==typeof t&&(e=t,t=void 0);var o=e||a.messages.general.required;return this.validators.unshift(Object.assign({},r,{validator:this.requiredValidator,message:o,type:"required"})),this},w.prototype.ref=function(t){return this.options.ref=t,this},w.prototype.getDefault=function(t,e){var r="function"==typeof this.defaultValue?this.defaultValue.call(t):this.defaultValue;if(null!=r){"object"!==s(r)||this.options&&this.options.shared||(r=_.clone(r));var n=this.applySetters(r,t,e);return n&&n.$isSingleNested&&(n.$__parent=t),n}return r},
|
|
379
379
|
/*!
|
|
380
380
|
* Applies setters without casting
|
|
381
381
|
*
|
|
382
382
|
* @api private
|
|
383
383
|
*/
|
|
384
|
-
|
|
384
|
+
w.prototype._applySetters=function(t,e){var r,n=t,i=this.setters,s=o(_.clone(i).reverse());try{for(s.s();!(r=s.n()).done;){n=r.value.call(e,n,this)}}catch(t){s.e(t)}finally{s.f()}return n},
|
|
385
385
|
/*!
|
|
386
386
|
* ignore
|
|
387
387
|
*/
|
|
388
|
-
|
|
388
|
+
w.prototype._castNullish=function(t){return t},w.prototype.applySetters=function(t,e,r,n,o){var i=this._applySetters(t,e,r,n,o);return null==i?this._castNullish(i):i=this.cast(i,e,r,n,o)},w.prototype.applyGetters=function(t,e){var r=t,n=this.getters,o=n.length;if(0===o)return r;for(var i=0;i<o;++i)r=n[i].call(e,r,this);return r},w.prototype.select=function(t){return this.selected=!!t,this},w.prototype.doValidate=function(t,e,r,n){var o=!1,i=this.path,a=this.validators.filter((function(t){return null!=t&&"object"===s(t)})),u=a.length;if(!u)return e(null);var c=this;function l(t,r){if(!o)if(void 0===t||t)--u<=0&&h((function(){e(null)}));else{var n=r.ErrorConstructor||b;(o=new n(r))[m]=!0,h((function(){e(o)}))}}a.forEach((function(e){if(!o){var s,a=e.validator,u=_.clone(e);if(u.path=n&&n.path?n.path:i,u.value=t,a instanceof RegExp)l(a.test(t),u);else if("function"==typeof a)if(void 0!==t||a===c.requiredValidator)if(u.isAsync)!
|
|
389
389
|
/*!
|
|
390
390
|
* Handle async validators
|
|
391
391
|
*/
|
|
392
|
-
function(t,e,r,n,o){var i=!1,s=t.call(e,r,(function(t,e){i||(i=!0,e&&(n.message=e),o(t,n))}));"boolean"==typeof s?(i=!0,o(s,n)):s&&"function"==typeof s.then&&s.then((function(t){i||(i=!0,o(t,n))}),(function(t){i||(i=!0,n.reason=t,n.message=t.message,o(!1,n))}))}(a,r,t,u,l);else{try{s=u.propsParameter?a.call(r,t,u):a.call(r,t)}catch(t){s=!1,u.reason=t,t.message&&(u.message=t.message)}null!=s&&"function"==typeof s.then?s.then((function(t){l(t,u)}),(function(t){u.reason=t,u.message=t.message,l(s=!1,u)})):l(s,u)}else l(!0,u)}}))},
|
|
392
|
+
function(t,e,r,n,o){var i=!1,s=t.call(e,r,(function(t,e){i||(i=!0,e&&(n.message=e),o(t,n))}));"boolean"==typeof s?(i=!0,o(s,n)):s&&"function"==typeof s.then&&s.then((function(t){i||(i=!0,o(t,n))}),(function(t){i||(i=!0,n.reason=t,n.message=t.message,o(!1,n))}))}(a,r,t,u,l);else{try{s=u.propsParameter?a.call(r,t,u):a.call(r,t)}catch(t){s=!1,u.reason=t,t.message&&(u.message=t.message)}null!=s&&"function"==typeof s.then?s.then((function(t){l(t,u)}),(function(t){u.reason=t,u.message=t.message,l(s=!1,u)})):l(s,u)}else l(!0,u)}}))},w.prototype.doValidateSync=function(t,e,r){var n=this.path;if(!this.validators.length)return null;var o=this.validators;if(void 0===t){if(!(this.validators.length>0&&"required"===this.validators[0].type))return null;o=[this.validators[0]]}var i=null;return o.forEach((function(o){if(!i&&null!=o&&"object"===s(o)){var u,c=o.validator,l=_.clone(o);if(l.path=r&&r.path?r.path:n,l.value=t,!c.isAsync)if(c instanceof RegExp)a(c.test(t),l);else if("function"==typeof c){try{u=l.propsParameter?c.call(e,t,l):c.call(e,t)}catch(t){u=!1,l.reason=t}null!=u&&"function"==typeof u.then||a(u,l)}}})),i;function a(t,e){if(!i&&void 0!==t&&!t){var r=e.ErrorConstructor||b;(i=new r(e))[m]=!0}}},w._isRef=function(t,e,r,o){var i=o&&t.options&&(t.options.ref||t.options.refPath);if(!i&&r&&null!=r.$__){var s=r.$__fullPath(t.path);i=(r.ownerDocument?r.ownerDocument():r).populated(s)||r.populated(t.path)}if(i){if(null==e)return!0;if(!n.isBuffer(e)&&"Binary"!==e._bsontype&&_.isObject(e))return!0}return!1},w.prototype.$conditionalHandlers={$all:function(t){var e=this;return Array.isArray(t)?t.map((function(t){return e.castForQuery(t)})):[this.castForQuery(t)]},$eq:S,$in:A,$ne:S,$nin:A,$exists:c,$type:l},
|
|
393
393
|
/*!
|
|
394
394
|
* Wraps `castForQuery` to handle context
|
|
395
395
|
*/
|
|
396
|
-
|
|
396
|
+
w.prototype.castForQueryWrapper=function(t){if(this.$$context=t.context,"$conditional"in t){var e=this.castForQuery(t.$conditional,t.val);return this.$$context=null,e}if(t.$skipQueryCastForUpdate||t.$applySetters){var r=this._castForQuery(t.val);return this.$$context=null,r}var n=this.castForQuery(t.val);return this.$$context=null,n},w.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(!(r=this.$conditionalHandlers[t]))throw new Error("Can't use "+t);return r.call(this,e)}return e=t,this._castForQuery(e)},
|
|
397
397
|
/*!
|
|
398
398
|
* Internal switch for runSetters
|
|
399
399
|
*
|
|
400
400
|
* @api private
|
|
401
401
|
*/
|
|
402
|
-
|
|
402
|
+
w.prototype._castForQuery=function(t){return this.applySetters(t,this.$$context)},w.checkRequired=function(t){return arguments.length>0&&(this._checkRequired=t),this._checkRequired},w.prototype.checkRequired=function(t){return null!=t},
|
|
403
403
|
/*!
|
|
404
404
|
* ignore
|
|
405
405
|
*/
|
|
406
|
-
|
|
406
|
+
w.prototype.clone=function(){var t=Object.assign({},this.options),e=new this.constructor(this.path,t,this.instance);return e.validators=this.validators.slice(),void 0!==this.requiredValidator&&(e.requiredValidator=this.requiredValidator),void 0!==this.defaultValue&&(e.defaultValue=this.defaultValue),void 0!==this.$immutable&&void 0===this.options.immutable&&(e.$immutable=this.$immutable,p(e)),void 0!==this._index&&(e._index=this._index),void 0!==this.selected&&(e.selected=this.selected),void 0!==this.isRequired&&(e.isRequired=this.isRequired),void 0!==this.originalRequiredValue&&(e.originalRequiredValue=this.originalRequiredValue),e.getters=this.getters.slice(),e.setters=this.setters.slice(),e},
|
|
407
407
|
/*!
|
|
408
408
|
* Module exports.
|
|
409
409
|
*/
|
|
410
|
-
t.exports=e=
|
|
410
|
+
t.exports=e=w,e.CastError=g,e.ValidatorError=b}).call(this,r(1).Buffer)},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var u,c=[],l=!1,f=-1;function p(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&h())}function h(){if(!l){var t=a(p);l=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;)u&&u[f].run();f=-1,e=c.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function d(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new y(t,e)),1!==c.length||l||a(h)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=d,o.addListener=d,o.once=d,o.off=d,o.removeListener=d,o.removeAllListeners=d,o.emit=d,o.prependListener=d,o.prependOnceListener=d,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){"use strict";var n=r(28),o=function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),null==e)return this;Object.assign(this,n(e))},i=r(10);Object.defineProperty(o.prototype,"type",i),Object.defineProperty(o.prototype,"validate",i),Object.defineProperty(o.prototype,"cast",i),Object.defineProperty(o.prototype,"required",i),Object.defineProperty(o.prototype,"default",i),Object.defineProperty(o.prototype,"ref",i),Object.defineProperty(o.prototype,"select",i),Object.defineProperty(o.prototype,"index",i),Object.defineProperty(o.prototype,"unique",i),Object.defineProperty(o.prototype,"immutable",i),Object.defineProperty(o.prototype,"sparse",i),Object.defineProperty(o.prototype,"text",i),Object.defineProperty(o.prototype,"transform",i),t.exports=o},function(t,e,r){"use strict";t.exports=Object.freeze({enumerable:!0,configurable:!0,writable:!0,value:void 0})},function(t,e){function r(t){return(r="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 n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(n=window)}t.exports=n},function(t,e,r){"use strict";
|
|
411
411
|
/*!
|
|
412
412
|
* Module dependencies.
|
|
413
413
|
*/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){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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 s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(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=c(t);if(e){var o=c(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return u(this,r)}}function u(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 c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var l=r(14),f=r(3),p=r(4),h=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&&s(t,e)}(l,t);var e,r,n,c=a(l);function l(t,e,r,n,i){var s;if(o(this,l),arguments.length>0){var a=y(e),f=d(i),p=_(null,t,a,r,f);(s=c.call(this,p)).init(t,e,r,n,i)}else s=c.call(this,_());return u(s)}
|
|
@@ -575,7 +575,8 @@ function p(t){for(var e,r=Object.keys(t.errors||{}),n=r.length,o=[],i=0;i<n;++i)
|
|
|
575
575
|
f.prototype[l.inspect.custom]=f.prototype.inspect)
|
|
576
576
|
/*!
|
|
577
577
|
* Helper for JSON.stringify
|
|
578
|
-
|
|
578
|
+
* Ensure `name` and `message` show up in toJSON output re: gh-9847
|
|
579
|
+
*/,Object.defineProperty(f.prototype,"toJSON",{enumerable:!1,writable:!1,configurable:!0,value:function(){return Object.assign({},this,{name:this.name,message:this.message})}}),Object.defineProperty(f.prototype,"name",{value:"ValidationError"}),t.exports=f},function(t,e,r){"use strict";
|
|
579
580
|
/*!
|
|
580
581
|
* Module dependencies.
|
|
581
582
|
*/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){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(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=a(t);if(e){var o=a(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return s(this,r)}}function s(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 a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u=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&&o(t,e)}(r,t);var e=i(r);function r(t,n,o){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),n=n||"Field `"+t+"` is not in schema and strict mode is set to throw.",(i=e.call(this,n)).isImmutableError=!!o,i.path=t,i}return r}(r(5));Object.defineProperty(u.prototype,"name",{value:"StrictModeError"}),t.exports=u},function(t,e,r){"use strict";
|
|
@@ -699,7 +700,7 @@ A.prototype=Object.create(f.prototype),A.prototype.constructor=A,A.prototype.Opt
|
|
|
699
700
|
/*!
|
|
700
701
|
* ignore
|
|
701
702
|
*/
|
|
702
|
-
A._checkRequired=f.prototype.checkRequired,A.checkRequired=f.checkRequired,A.prototype.checkRequired=function(t,e){return f._isRef(this,t,e,!0)?!!t:("function"==typeof this.constructor.checkRequired?this.constructor.checkRequired():A.checkRequired())(t)},A.prototype.enum=function(){for(var t=this;;){var e=_(t,"caster.instance");if("Array"!==e){if("String"!==e&&"Number"!==e)throw new Error("`enum` can only be set on an array of strings or numbers , not "+e);break}t=t.caster}var r=arguments;return!Array.isArray(arguments)&&g.isObject(arguments)&&(r=g.object.vals(r)),t.caster.enum.apply(t.caster,r),this},A.prototype.applyGetters=function(t,e){return this.caster.options&&this.caster.options.ref?t:f.prototype.applyGetters.call(this,t,e)},A.prototype._applySetters=function(t,e,r,n){if(this.casterConstructor instanceof A&&A.options.castNonArrays&&!this[S]){for(var o=0,i=this;null!=i&&i instanceof A&&!i.$isMongooseDocumentArray;)++o,i=i.casterConstructor;if(null!=t&&t.length>0){var s=y(t);if(s.min===s.max&&s.max<o&&s.containsNonArrayItem)for(var a=s.max;a<o;++a)t=[t]}}return f.prototype._applySetters.call(this,t,e,r,n)},A.prototype.cast=function(t,e,n,o,s){var a,u;if(i||(i=r(56).Array),Array.isArray(t)){if(!t.length&&e){var l=e.schema.indexedPaths(),f=this.path;for(a=0,u=l.length;a<u;++a){var y=l[a][0][f];if("2dsphere"===y||"2d"===y)return}var d=this.path.endsWith(".coordinates")?this.path.substr(0,this.path.lastIndexOf(".")):null;if(null!=d)for(a=0,u=l.length;a<u;++a){if("2dsphere"===l[a][0][d])return}}if(t&&t.isMongooseArray?t&&t.isMongooseArray&&(t=i(t,_(s,"path",null)||this._arrayPath||this.path,e,this)):t=i(t,_(s,"path",null)||this._arrayPath||this.path,e,this),null!=e&&null!=e.$__&&e.populated(this.path))return t;var m=this.caster;if(m&&this.casterConstructor!==h)try{var g=t.length;for(a=0;a<g;a++){if("Number"===m.instance&&void 0===t[a])throw new c("Mongoose number arrays disallow storing undefined");var b={};m.$isMongooseArray&&(null!=s&&null!=s.arrayPath?b.arrayPath=s.arrayPath+"."+a:null!=this.caster._arrayParentPath&&(b.arrayPath=this.caster._arrayParentPath+"."+a)),t[a]=m.applySetters(t[a],e,n,void 0,b)}}catch(e){throw new p("["+e.kind+"]",v.inspect(t),this.path+"."+a,e,this)}return t}if(n||A.options.castNonArrays)return e&&n&&e.markModified(this.path),this.cast([t],e,n);throw new p("Array",v.inspect(t),this.path,null,this)},
|
|
703
|
+
A._checkRequired=f.prototype.checkRequired,A.checkRequired=f.checkRequired,A.prototype.checkRequired=function(t,e){return f._isRef(this,t,e,!0)?!!t:("function"==typeof this.constructor.checkRequired?this.constructor.checkRequired():A.checkRequired())(t)},A.prototype.enum=function(){for(var t=this;;){var e=_(t,"caster.instance");if("Array"!==e){if("String"!==e&&"Number"!==e)throw new Error("`enum` can only be set on an array of strings or numbers , not "+e);break}t=t.caster}var r=arguments;return!Array.isArray(arguments)&&g.isObject(arguments)&&(r=g.object.vals(r)),t.caster.enum.apply(t.caster,r),this},A.prototype.applyGetters=function(t,e){return this.caster.options&&this.caster.options.ref?t:f.prototype.applyGetters.call(this,t,e)},A.prototype._applySetters=function(t,e,r,n){if(this.casterConstructor instanceof A&&A.options.castNonArrays&&!this[S]){for(var o=0,i=this;null!=i&&i instanceof A&&!i.$isMongooseDocumentArray;)++o,i=i.casterConstructor;if(null!=t&&t.length>0){var s=y(t);if(s.min===s.max&&s.max<o&&s.containsNonArrayItem)for(var a=s.max;a<o;++a)t=[t]}}return f.prototype._applySetters.call(this,t,e,r,n)},A.prototype.cast=function(t,e,n,o,s){var a,u;if(i||(i=r(56).Array),Array.isArray(t)){if(!t.length&&e){var l=e.schema.indexedPaths(),f=this.path;for(a=0,u=l.length;a<u;++a){var y=l[a][0][f];if("2dsphere"===y||"2d"===y)return}var d=this.path.endsWith(".coordinates")?this.path.substr(0,this.path.lastIndexOf(".")):null;if(null!=d)for(a=0,u=l.length;a<u;++a){if("2dsphere"===l[a][0][d])return}}if(t&&t.isMongooseArray?t&&t.isMongooseArray&&(t=i(t,_(s,"path",null)||this._arrayPath||this.path,e,this)):t=i(t,_(s,"path",null)||this._arrayPath||this.path,e,this),null!=e&&null!=e.$__&&e.populated(this.path)&&n)return t;var m=this.caster;if(m&&this.casterConstructor!==h)try{var g=t.length;for(a=0;a<g;a++){if("Number"===m.instance&&void 0===t[a])throw new c("Mongoose number arrays disallow storing undefined");var b={};m.$isMongooseArray&&(null!=s&&null!=s.arrayPath?b.arrayPath=s.arrayPath+"."+a:null!=this.caster._arrayParentPath&&(b.arrayPath=this.caster._arrayParentPath+"."+a)),t[a]=m.applySetters(t[a],e,n,void 0,b)}}catch(e){throw new p("["+e.kind+"]",v.inspect(t),this.path+"."+a,e,this)}return t}if(n||A.options.castNonArrays)return e&&n&&e.markModified(this.path),this.cast([t],e,n);throw new p("Array",v.inspect(t),this.path,null,this)},
|
|
703
704
|
/*!
|
|
704
705
|
* Ignore
|
|
705
706
|
*/
|
|
@@ -913,12 +914,12 @@ s.mixin={_subtype:void 0,_markModified:function(){var t=this[u];return t&&t.mark
|
|
|
913
914
|
/*!
|
|
914
915
|
* Module exports.
|
|
915
916
|
*/
|
|
916
|
-
s.Binary=n,t.exports=s},function(t,e,r){"use strict";var n=r(15).get().ObjectId,o=r(22);t.exports=function(t){if(null==t)return t;if(t instanceof n)return t;if(t._id){if(t._id instanceof n)return t._id;if(t._id.toString instanceof Function)return new n(t._id.toString())}if(t.toString instanceof Function)return new n(t.toString());o.ok(!1)}},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)}function o(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 i(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 i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i(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 s(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 a(t,e,r){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}function u(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 c(t){var e="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return l(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)})(t)}function l(t,e,r){return(l=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&p(o,r.prototype),o}).apply(null,arguments)}function f(){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}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var y=r(25),d=r(2).deepEqual,_=r(3),m=r(88),v=r(4),g=r(47),b=r(0).populateModelSymbol,w=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&&p(t,e)}(v,t);var e,r,n,i,c,l=(e=v,r=f(),function(){var t,n=h(e);if(r){var o=h(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return u(this,t)});function v(t,e,r,n){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,v),null!=t&&"Object"===t.constructor.name&&(t=Object.keys(t).reduce((function(e,r){return e.concat([[r,t[r]]])}),[])),(o=l.call(this,t)).$__parent=null!=r&&null!=r.$__?r:null,o.$__path=e,o.$__schemaType=null==n?new y(e):n,o.$__runDeferred(),o}return n=v,(i=[{key:"$init",value:function(t,e){O(t),a(h(v.prototype),"set",this).call(this,t,e),null!=e&&e.$isSingleNested&&(e.$basePath=this.$__path+"."+t)}},{key:"$__set",value:function(t,e){a(h(v.prototype),"set",this).call(this,t,e)}},{key:"get",value:function(t,e){return!1===(e=e||{}).getters?a(h(v.prototype),"get",this).call(this,t):this.$__schemaType.applyGetters(a(h(v.prototype),"get",this).call(this,t),this.$__parent)}},{key:"set",value:function(t,e){if(O(t),e=m(e),null==this.$__schemaType)return this.$__deferred=this.$__deferred||[],void this.$__deferred.push({key:t,value:e});var r=this.$__path+"."+t,n=null!=this.$__parent&&this.$__parent.$__?this.$__parent.populated(r)||this.$__parent.populated(this.$__path):null,o=this.get(t);if(null!=n)null==e.$__&&(e=new n.options[b](e)),e.$__.wasPopulated=!0;else try{e=this.$__schemaType.applySetters(e,this.$__parent,!1,this.get(t))}catch(t){if(null!=this.$__parent&&null!=this.$__parent.$__)return void this.$__parent.invalidate(r,t);throw t}a(h(v.prototype),"set",this).call(this,t,e),null!=e&&e.$isSingleNested&&(e.$basePath=this.$__path+"."+t);var i=this.$__parent;null==i||null==i.$__||d(e,o)||i.markModified(this.$__path+"."+t)}},{key:"clear",value:function(){a(h(v.prototype),"clear",this).call(this);var t=this.$__parent;null!=t&&t.markModified(this.$__path)}},{key:"delete",value:function(t){this.set(t,void 0),a(h(v.prototype),"delete",this).call(this,t)}},{key:"toBSON",value:function(){return new Map(this)}},{key:"toObject",value:function(t){if(_(t,"flattenMaps")){var e,r={},n=o(this.keys());try{for(n.s();!(e=n.n()).done;){var i=e.value;r[i]=this.get(i)}}catch(t){n.e(t)}finally{n.f()}return r}return new Map(this)}},{key:"toJSON",value:function(){var t,e={},r=o(this.keys());try{for(r.s();!(t=r.n()).done;){var n=t.value;e[n]=this.get(n)}}catch(t){r.e(t)}finally{r.f()}return e}},{key:"inspect",value:function(){return new Map(this)}},{key:"$__runDeferred",value:function(){if(this.$__deferred){var t,e=o(this.$__deferred);try{for(e.s();!(t=e.n()).done;){var r=t.value;this.set(r.key,r.value)}}catch(t){e.e(t)}finally{e.f()}this.$__deferred=null}}}])&&s(n.prototype,i),c&&s(n,c),v}(c(Map));
|
|
917
|
+
s.Binary=n,t.exports=s},function(t,e,r){"use strict";var n=r(15).get().ObjectId,o=r(22);t.exports=function(t){if(null==t)return t;if(t instanceof n)return t;if(t._id){if(t._id instanceof n)return t._id;if(t._id.toString instanceof Function)return new n(t._id.toString())}if(t.toString instanceof Function)return new n(t.toString());o.ok(!1)}},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)}function o(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 i(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 i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i(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 s(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 a(t,e,r){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}function u(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 c(t){var e="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return l(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)})(t)}function l(t,e,r){return(l=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&p(o,r.prototype),o}).apply(null,arguments)}function f(){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}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var y=r(25),d=r(2).deepEqual,_=r(3),m=r(88),v=r(4),g=r(47),b=r(0).populateModelSymbol,w=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&&p(t,e)}(v,t);var e,r,n,i,c,l=(e=v,r=f(),function(){var t,n=h(e);if(r){var o=h(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return u(this,t)});function v(t,e,r,n){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,v),null!=t&&"Object"===t.constructor.name&&(t=Object.keys(t).reduce((function(e,r){return e.concat([[r,t[r]]])}),[])),(o=l.call(this,t)).$__parent=null!=r&&null!=r.$__?r:null,o.$__path=e,o.$__schemaType=null==n?new y(e):n,o.$__runDeferred(),o}return n=v,(i=[{key:"$init",value:function(t,e){O(t),a(h(v.prototype),"set",this).call(this,t,e),null!=e&&e.$isSingleNested&&(e.$basePath=this.$__path+"."+t)}},{key:"$__set",value:function(t,e){a(h(v.prototype),"set",this).call(this,t,e)}},{key:"get",value:function(t,e){return!1===(e=e||{}).getters?a(h(v.prototype),"get",this).call(this,t):this.$__schemaType.applyGetters(a(h(v.prototype),"get",this).call(this,t),this.$__parent)}},{key:"set",value:function(t,e){if(O(t),e=m(e),null==this.$__schemaType)return this.$__deferred=this.$__deferred||[],void this.$__deferred.push({key:t,value:e});var r=this.$__path+"."+t,n=null!=this.$__parent&&this.$__parent.$__?this.$__parent.populated(r)||this.$__parent.populated(this.$__path):null,o=this.get(t);if(null!=n)null==e.$__&&(e=new n.options[b](e)),e.$__.wasPopulated=!0;else try{e=this.$__schemaType.applySetters(e,this.$__parent,!1,this.get(t),{path:r})}catch(t){if(null!=this.$__parent&&null!=this.$__parent.$__)return void this.$__parent.invalidate(r,t);throw t}a(h(v.prototype),"set",this).call(this,t,e),null!=e&&e.$isSingleNested&&(e.$basePath=this.$__path+"."+t);var i=this.$__parent;null==i||null==i.$__||d(e,o)||i.markModified(this.$__path+"."+t)}},{key:"clear",value:function(){a(h(v.prototype),"clear",this).call(this);var t=this.$__parent;null!=t&&t.markModified(this.$__path)}},{key:"delete",value:function(t){this.set(t,void 0),a(h(v.prototype),"delete",this).call(this,t)}},{key:"toBSON",value:function(){return new Map(this)}},{key:"toObject",value:function(t){if(_(t,"flattenMaps")){var e,r={},n=o(this.keys());try{for(n.s();!(e=n.n()).done;){var i=e.value;r[i]=this.get(i)}}catch(t){n.e(t)}finally{n.f()}return r}return new Map(this)}},{key:"toJSON",value:function(){var t,e={},r=o(this.keys());try{for(r.s();!(t=r.n()).done;){var n=t.value;e[n]=this.get(n)}}catch(t){r.e(t)}finally{r.f()}return e}},{key:"inspect",value:function(){return new Map(this)}},{key:"$__runDeferred",value:function(){if(this.$__deferred){var t,e=o(this.$__deferred);try{for(e.s();!(t=e.n()).done;){var r=t.value;this.set(r.key,r.value)}}catch(t){e.e(t)}finally{e.f()}this.$__deferred=null}}}])&&s(n.prototype,i),c&&s(n,c),v}(c(Map));
|
|
917
918
|
/*!
|
|
918
919
|
* Since maps are stored as objects under the hood, keys must be strings
|
|
919
920
|
* and can't contain any invalid characters
|
|
920
921
|
*/
|
|
921
|
-
function O(t){var e=n(t);if("string"!==e)throw new TypeError("Mongoose maps only support string keys, got ".concat(e));if(t.startsWith("$"))throw new Error('Mongoose maps do not support keys that start with "$", got "'.concat(t,'"'));if(t.includes("."))throw new Error('Mongoose maps do not support keys that contain ".", got "'.concat(t,'"'));if(g.has(t))throw new Error('Mongoose maps do not support reserved key name "'.concat(t,'"'))}v.inspect.custom&&Object.defineProperty(w.prototype,v.inspect.custom,{enumerable:!1,writable:!1,configurable:!1,value:w.prototype.inspect}),Object.defineProperty(w.prototype,"$__set",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__parent",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__path",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__schemaType",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$isMongooseMap",{enumerable:!1,writable:!1,configurable:!1,value:!0}),Object.defineProperty(w.prototype,"$__deferredCalls",{enumerable:!1,writable:!1,configurable:!1,value:!0}),t.exports=w},function(t,e,r){"use strict";var n=r(2);t.exports=function(t){return n.isPOJO(t)&&null!=t.$__&&null!=t._doc?t._doc:t}},function(t,e,r){"use strict";function n(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 o(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 o(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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 o(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}var i=r(6),s=r(50),a=r(17).internalToObjectOptions,u=r(24),c=r(0).documentArrayParent;function l(t,e,r,o,s){var a=this;this.$isSingleNested=!0;var u=null!=s&&s.priorDoc,c=null;if(u&&(this._doc=Object.assign({},s.priorDoc._doc),delete this._doc[this.schema.options.discriminatorKey],c=Object.keys(s.priorDoc._doc||{}).filter((function(t){return t!==a.schema.options.discriminatorKey}))),null!=r&&(s=Object.assign({},s,{isNew:r.isNew,defaults:r.$__.$options.defaults})),i.call(this,t,e,o,s),u){var l,f=n(c);try{for(f.s();!(l=f.n()).done;){var p=l.value;if(!this.$__.activePaths.states.modify[p]&&!this.$__.activePaths.states.default[p]&&!this.$__.$setCalled.has(p)){var h=this.schema.path(p),y=null==h?void 0:h.getDefault(this);void 0===y?delete this._doc[p]:(this._doc[p]=y,this.$__.activePaths.default(p))}}}catch(t){f.e(t)}finally{f.f()}delete s.priorDoc,delete this.$__.$options.priorDoc}}t.exports=l,l.prototype=Object.create(i.prototype),l.prototype.toBSON=function(){return this.toObject(a)},l.prototype.save=function(t,e){var r=this;return"function"==typeof t&&(e=t,t={}),(t=t||{}).suppressWarning||console.warn("mongoose: calling `save()` on a subdoc does **not** save the document to MongoDB, it only runs save middleware. Use `subdoc.save({ suppressWarning: true })` to hide this warning if you're sure this behavior is right for your app."),u(e,(function(t){r.$__save(t)}))},l.prototype.$__save=function(t){var e=this;return s((function(){return t(null,e)}))},l.prototype.$isValid=function(t){return this.$__parent&&this.$basePath?this.$__parent.$isValid([this.$basePath,t].join(".")):i.prototype.$isValid.call(this,t)},l.prototype.markModified=function(t){if(i.prototype.markModified.call(this,t),this.$__parent&&this.$basePath){if(this.$__parent.isDirectModified(this.$basePath))return;this.$__parent.markModified([this.$basePath,t].join("."),this)}},l.prototype.isModified=function(t,e){var r=this;return this.$__parent&&this.$basePath?Array.isArray(t)||"string"==typeof t?(t=(t=Array.isArray(t)?t:t.split(" ")).map((function(t){return[r.$basePath,t].join(".")})),this.$__parent.isModified(t,e)):this.$__parent.isModified(this.$basePath):i.prototype.isModified.call(this,t,e)},l.prototype.$markValid=function(t){i.prototype.$markValid.call(this,t),this.$__parent&&this.$basePath&&this.$__parent.$markValid([this.$basePath,t].join("."))},
|
|
922
|
+
function O(t){var e=n(t);if("string"!==e)throw new TypeError("Mongoose maps only support string keys, got ".concat(e));if(t.startsWith("$"))throw new Error('Mongoose maps do not support keys that start with "$", got "'.concat(t,'"'));if(t.includes("."))throw new Error('Mongoose maps do not support keys that contain ".", got "'.concat(t,'"'));if(g.has(t))throw new Error('Mongoose maps do not support reserved key name "'.concat(t,'"'))}v.inspect.custom&&Object.defineProperty(w.prototype,v.inspect.custom,{enumerable:!1,writable:!1,configurable:!1,value:w.prototype.inspect}),Object.defineProperty(w.prototype,"$__set",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__parent",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__path",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$__schemaType",{enumerable:!1,writable:!0,configurable:!1}),Object.defineProperty(w.prototype,"$isMongooseMap",{enumerable:!1,writable:!1,configurable:!1,value:!0}),Object.defineProperty(w.prototype,"$__deferredCalls",{enumerable:!1,writable:!1,configurable:!1,value:!0}),t.exports=w},function(t,e,r){"use strict";var n=r(2);t.exports=function(t){return n.isPOJO(t)&&null!=t.$__&&null!=t._doc?t._doc:t}},function(t,e,r){"use strict";function n(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 o(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 o(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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 o(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}var i=r(6),s=r(50),a=r(17).internalToObjectOptions,u=r(24),c=r(0).documentArrayParent;function l(t,e,r,o,s){var a=this;this.$isSingleNested=!0,null!=s&&null!=s.path&&(this.$basePath=s.path);var u=null!=s&&s.priorDoc,c=null;if(u&&(this._doc=Object.assign({},s.priorDoc._doc),delete this._doc[this.schema.options.discriminatorKey],c=Object.keys(s.priorDoc._doc||{}).filter((function(t){return t!==a.schema.options.discriminatorKey}))),null!=r&&(s=Object.assign({},s,{isNew:r.isNew,defaults:r.$__.$options.defaults})),i.call(this,t,e,o,s),u){var l,f=n(c);try{for(f.s();!(l=f.n()).done;){var p=l.value;if(!this.$__.activePaths.states.modify[p]&&!this.$__.activePaths.states.default[p]&&!this.$__.$setCalled.has(p)){var h=this.schema.path(p),y=null==h?void 0:h.getDefault(this);void 0===y?delete this._doc[p]:(this._doc[p]=y,this.$__.activePaths.default(p))}}}catch(t){f.e(t)}finally{f.f()}delete s.priorDoc,delete this.$__.$options.priorDoc}}t.exports=l,l.prototype=Object.create(i.prototype),l.prototype.toBSON=function(){return this.toObject(a)},l.prototype.save=function(t,e){var r=this;return"function"==typeof t&&(e=t,t={}),(t=t||{}).suppressWarning||console.warn("mongoose: calling `save()` on a subdoc does **not** save the document to MongoDB, it only runs save middleware. Use `subdoc.save({ suppressWarning: true })` to hide this warning if you're sure this behavior is right for your app."),u(e,(function(t){r.$__save(t)}))},l.prototype.$__save=function(t){var e=this;return s((function(){return t(null,e)}))},l.prototype.$isValid=function(t){return this.$__parent&&this.$basePath?this.$__parent.$isValid([this.$basePath,t].join(".")):i.prototype.$isValid.call(this,t)},l.prototype.markModified=function(t){if(i.prototype.markModified.call(this,t),this.$__parent&&this.$basePath){if(this.$__parent.isDirectModified(this.$basePath))return;this.$__parent.markModified([this.$basePath,t].join("."),this)}},l.prototype.isModified=function(t,e){var r=this;return this.$__parent&&this.$basePath?Array.isArray(t)||"string"==typeof t?(t=(t=Array.isArray(t)?t:t.split(" ")).map((function(t){return[r.$basePath,t].join(".")})),this.$__parent.isModified(t,e)):this.$__parent.isModified(this.$basePath):i.prototype.isModified.call(this,t,e)},l.prototype.$markValid=function(t){i.prototype.$markValid.call(this,t),this.$__parent&&this.$basePath&&this.$__parent.$markValid([this.$basePath,t].join("."))},
|
|
922
923
|
/*!
|
|
923
924
|
* ignore
|
|
924
925
|
*/
|
|
@@ -1392,7 +1393,7 @@ function g(t,e){o||(o=r(89));var n=function(t,e,r){var n=this;this.$__parent=r,o
|
|
|
1392
1393
|
/*!
|
|
1393
1394
|
* ignore
|
|
1394
1395
|
*/
|
|
1395
|
-
v.prototype.$conditionalHandlers.$near=v.prototype.$conditionalHandlers.$nearSphere=h.cast$near,v.prototype.$conditionalHandlers.$within=v.prototype.$conditionalHandlers.$geoWithin=h.cast$within,v.prototype.$conditionalHandlers.$geoIntersects=h.cast$geoIntersects,v.prototype.$conditionalHandlers.$minDistance=f,v.prototype.$conditionalHandlers.$maxDistance=f,v.prototype.$conditionalHandlers.$exists=l,v.prototype.cast=function(t,e,r,o){if(t&&t.$isSingleNested&&t.parent===e)return t;if(null!=t&&("object"!==n(t)||Array.isArray(t)))throw new a(this.path,t);var
|
|
1396
|
+
v.prototype.$conditionalHandlers.$near=v.prototype.$conditionalHandlers.$nearSphere=h.cast$near,v.prototype.$conditionalHandlers.$within=v.prototype.$conditionalHandlers.$geoWithin=h.cast$within,v.prototype.$conditionalHandlers.$geoIntersects=h.cast$geoIntersects,v.prototype.$conditionalHandlers.$minDistance=f,v.prototype.$conditionalHandlers.$maxDistance=f,v.prototype.$conditionalHandlers.$exists=l,v.prototype.cast=function(t,e,r,o,i){if(t&&t.$isSingleNested&&t.parent===e)return t;if(null!=t&&("object"!==n(t)||Array.isArray(t)))throw new a(this.path,t);var s,u=d(this.caster,t),c=y(e,"$__.selected",{}),l=this.path,f=Object.keys(c).reduce((function(t,e){return e.startsWith(l+".")&&(t[e.substr(l.length+1)]=c[e]),t}),{});return i=Object.assign({},i,{priorDoc:o}),r?((s=new u(void 0,f,e)).init(t),s):0===Object.keys(t).length?new u({},f,e,void 0,i):new u(t,f,e,void 0,i)},v.prototype.castForQuery=function(t,e,r){var n;if(2===arguments.length){if(!(n=this.$conditionalHandlers[t]))throw new Error("Can't use "+t);return n.call(this,e)}if(null==(e=t))return e;this.options.runSetters&&(e=this._applySetters(e));var o=d(this.caster,e),s=null!=r&&null!=r.strict?r.strict:void 0;try{e=new o(e,s)}catch(t){if(!(t instanceof i))throw new i("Embedded",e,this.path,t,this);throw t}return e},v.prototype.doValidate=function(t,e,r,n){var o=d(this.caster,t);if(n&&n.skipSchemaValidators)return t instanceof o||(t=new o(t,null,r)),t.validate(e);c.prototype.doValidate.call(this,t,(function(r){return r?e(r):t?void t.validate(e):e(null)}),r,n)},v.prototype.doValidateSync=function(t,e,r){if(!r||!r.skipSchemaValidators){var n=c.prototype.doValidateSync.call(this,t,e);if(n)return n}if(t)return t.validateSync()},v.prototype.discriminator=function(t,e,r){return e=p(this.caster,t,e,r),this.caster.discriminators[t]=g(e,this.caster),this.caster.discriminators[t]},v.defaultOptions={},v.set=c.set,
|
|
1396
1397
|
/*!
|
|
1397
1398
|
* ignore
|
|
1398
1399
|
*/
|
package/index.d.ts
CHANGED
|
@@ -546,7 +546,7 @@ declare module 'mongoose' {
|
|
|
546
546
|
populated(path: string): any;
|
|
547
547
|
|
|
548
548
|
/** Removes this document from the db. */
|
|
549
|
-
remove(options?: QueryOptions):
|
|
549
|
+
remove(options?: QueryOptions): Promise<this>;
|
|
550
550
|
remove(options?: QueryOptions, cb?: (err: CallbackError, res: any) => void): void;
|
|
551
551
|
|
|
552
552
|
/** Sends a replaceOne command with this document `_id` as the query selector. */
|
|
@@ -1421,7 +1421,7 @@ declare module 'mongoose' {
|
|
|
1421
1421
|
set?: (value: T, schematype?: this) => any;
|
|
1422
1422
|
|
|
1423
1423
|
/** array of allowed values for this path. Allowed for strings, numbers, and arrays of strings */
|
|
1424
|
-
enum?: Array<string | number | null>
|
|
1424
|
+
enum?: Array<string | number | null> | { [path: string]: string | number | null };
|
|
1425
1425
|
|
|
1426
1426
|
/** The default [subtype](http://bsonspec.org/spec.html) associated with this buffer when it is stored in MongoDB. Only allowed for buffer paths */
|
|
1427
1427
|
subtype?: number
|
package/lib/document.js
CHANGED
|
@@ -41,7 +41,6 @@ const isMongooseObject = utils.isMongooseObject;
|
|
|
41
41
|
const arrayAtomicsBackupSymbol = Symbol('mongoose.Array#atomicsBackup');
|
|
42
42
|
const arrayAtomicsSymbol = require('./helpers/symbols').arrayAtomicsSymbol;
|
|
43
43
|
const documentArrayParent = require('./helpers/symbols').documentArrayParent;
|
|
44
|
-
const documentIsSelected = require('./helpers/symbols').documentIsSelected;
|
|
45
44
|
const documentIsModified = require('./helpers/symbols').documentIsModified;
|
|
46
45
|
const documentModifiedPaths = require('./helpers/symbols').documentModifiedPaths;
|
|
47
46
|
const documentSchemaSymbol = require('./helpers/symbols').documentSchemaSymbol;
|
|
@@ -2111,7 +2110,7 @@ Document.prototype.isSelected = function isSelected(path) {
|
|
|
2111
2110
|
return !inclusive;
|
|
2112
2111
|
};
|
|
2113
2112
|
|
|
2114
|
-
Document.prototype
|
|
2113
|
+
Document.prototype.$__isSelected = Document.prototype.isSelected;
|
|
2115
2114
|
|
|
2116
2115
|
/**
|
|
2117
2116
|
* Checks if `path` was explicitly selected. If no projection, always returns
|
|
@@ -4135,7 +4134,6 @@ Document.prototype.$__fullPath = function(path) {
|
|
|
4135
4134
|
|
|
4136
4135
|
Document.prototype.getChanges = function() {
|
|
4137
4136
|
const delta = this.$__delta();
|
|
4138
|
-
|
|
4139
4137
|
const changes = delta ? delta[1] : {};
|
|
4140
4138
|
return changes;
|
|
4141
4139
|
};
|
package/lib/error/validation.js
CHANGED
|
@@ -67,13 +67,14 @@ if (util.inspect.custom) {
|
|
|
67
67
|
|
|
68
68
|
/*!
|
|
69
69
|
* Helper for JSON.stringify
|
|
70
|
+
* Ensure `name` and `message` show up in toJSON output re: gh-9847
|
|
70
71
|
*/
|
|
71
72
|
Object.defineProperty(ValidationError.prototype, 'toJSON', {
|
|
72
73
|
enumerable: false,
|
|
73
74
|
writable: false,
|
|
74
75
|
configurable: true,
|
|
75
76
|
value: function() {
|
|
76
|
-
return Object.assign({}, this, { message: this.message });
|
|
77
|
+
return Object.assign({}, this, { name: this.name, message: this.message });
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
|
|
@@ -43,7 +43,6 @@ module.exports = function getModelsMapForPopulate(model, docs, options) {
|
|
|
43
43
|
for (i = 0; i < len; i++) {
|
|
44
44
|
doc = docs[i];
|
|
45
45
|
let justOne = null;
|
|
46
|
-
|
|
47
46
|
schema = getSchemaTypes(modelSchema, doc, options.path);
|
|
48
47
|
// Special case: populating a path that's a DocumentArray unless
|
|
49
48
|
// there's an explicit `ref` or `refPath` re: gh-8946
|
|
@@ -174,9 +173,11 @@ module.exports = function getModelsMapForPopulate(model, docs, options) {
|
|
|
174
173
|
}
|
|
175
174
|
} else if (schema && !schema[schemaMixedSymbol]) {
|
|
176
175
|
// Skip Mixed types because we explicitly don't do casting on those.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
if (options.path.endsWith('.' + schema.path)) {
|
|
177
|
+
justOne = Array.isArray(schema) ?
|
|
178
|
+
schema.every(schema => !schema.$isMongooseArray) :
|
|
179
|
+
!schema.$isMongooseArray;
|
|
180
|
+
}
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
if (!modelNames) {
|
|
@@ -358,7 +359,6 @@ module.exports = function getModelsMapForPopulate(model, docs, options) {
|
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
|
-
|
|
362
362
|
return map;
|
|
363
363
|
|
|
364
364
|
function _getModelNames(doc, schema) {
|
|
@@ -20,7 +20,6 @@ const populateModelSymbol = require('../symbols').populateModelSymbol;
|
|
|
20
20
|
module.exports = function getSchemaTypes(schema, doc, path) {
|
|
21
21
|
const pathschema = schema.path(path);
|
|
22
22
|
const topLevelDoc = doc;
|
|
23
|
-
|
|
24
23
|
if (pathschema) {
|
|
25
24
|
return pathschema;
|
|
26
25
|
}
|
|
@@ -33,7 +32,6 @@ module.exports = function getSchemaTypes(schema, doc, path) {
|
|
|
33
32
|
while (p--) {
|
|
34
33
|
trypath = parts.slice(0, p).join('.');
|
|
35
34
|
foundschema = schema.path(trypath);
|
|
36
|
-
|
|
37
35
|
if (foundschema == null) {
|
|
38
36
|
continue;
|
|
39
37
|
}
|
|
@@ -117,7 +115,6 @@ module.exports = function getSchemaTypes(schema, doc, path) {
|
|
|
117
115
|
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
|
|
118
116
|
!foundschema.schema.$isSingleNested;
|
|
119
117
|
}
|
|
120
|
-
|
|
121
118
|
return ret;
|
|
122
119
|
}
|
|
123
120
|
} else if (p !== parts.length &&
|
|
@@ -153,7 +150,6 @@ module.exports = function getSchemaTypes(schema, doc, path) {
|
|
|
153
150
|
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
|
|
154
151
|
!model.schema.$isSingleNested;
|
|
155
152
|
}
|
|
156
|
-
|
|
157
153
|
return ret;
|
|
158
154
|
}
|
|
159
155
|
}
|
|
@@ -177,15 +173,12 @@ module.exports = function getSchemaTypes(schema, doc, path) {
|
|
|
177
173
|
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
|
|
178
174
|
!schema.$isSingleNested;
|
|
179
175
|
}
|
|
180
|
-
|
|
181
176
|
return ret;
|
|
182
177
|
}
|
|
183
178
|
}
|
|
184
|
-
|
|
185
179
|
return foundschema;
|
|
186
180
|
}
|
|
187
181
|
}
|
|
188
|
-
|
|
189
182
|
// look for arrays
|
|
190
183
|
const parts = path.split('.');
|
|
191
184
|
for (let i = 0; i < parts.length; ++i) {
|
package/lib/model.js
CHANGED
|
@@ -538,7 +538,6 @@ function operand(self, where, delta, data, val, op) {
|
|
|
538
538
|
op || (op = '$set');
|
|
539
539
|
if (!delta[op]) delta[op] = {};
|
|
540
540
|
delta[op][data.path] = val;
|
|
541
|
-
|
|
542
541
|
// disabled versioning?
|
|
543
542
|
if (self.schema.options.versionKey === false) return;
|
|
544
543
|
|
|
@@ -748,7 +747,6 @@ Model.prototype.$__delta = function() {
|
|
|
748
747
|
if (this.$__.version) {
|
|
749
748
|
this.$__version(where, delta);
|
|
750
749
|
}
|
|
751
|
-
|
|
752
750
|
return [where, delta];
|
|
753
751
|
};
|
|
754
752
|
|
|
@@ -4338,7 +4336,6 @@ function populate(model, docs, options, callback) {
|
|
|
4338
4336
|
}
|
|
4339
4337
|
|
|
4340
4338
|
const modelsMap = getModelsMapForPopulate(model, docs, options);
|
|
4341
|
-
|
|
4342
4339
|
if (modelsMap instanceof MongooseError) {
|
|
4343
4340
|
return immediate(function() {
|
|
4344
4341
|
callback(modelsMap);
|
|
@@ -4422,7 +4419,6 @@ function populate(model, docs, options, callback) {
|
|
|
4422
4419
|
} else if (mod.options.limit != null) {
|
|
4423
4420
|
assignmentOpts.originalLimit = mod.options.limit;
|
|
4424
4421
|
}
|
|
4425
|
-
|
|
4426
4422
|
params.push([mod, match, select, assignmentOpts, _next]);
|
|
4427
4423
|
}
|
|
4428
4424
|
|
|
@@ -4441,7 +4437,6 @@ function populate(model, docs, options, callback) {
|
|
|
4441
4437
|
for (const arr of params) {
|
|
4442
4438
|
_execPopulateQuery.apply(null, arr);
|
|
4443
4439
|
}
|
|
4444
|
-
|
|
4445
4440
|
function _next(err, valsFromDb) {
|
|
4446
4441
|
if (err != null) {
|
|
4447
4442
|
return callback(err, null);
|
|
@@ -4475,7 +4470,6 @@ function populate(model, docs, options, callback) {
|
|
|
4475
4470
|
|
|
4476
4471
|
function _execPopulateQuery(mod, match, select, assignmentOpts, callback) {
|
|
4477
4472
|
const subPopulate = utils.clone(mod.options.populate);
|
|
4478
|
-
|
|
4479
4473
|
const queryOptions = Object.assign({
|
|
4480
4474
|
skip: mod.options.skip,
|
|
4481
4475
|
limit: mod.options.limit,
|
|
@@ -147,7 +147,7 @@ SingleNestedPath.prototype.$conditionalHandlers.$exists = $exists;
|
|
|
147
147
|
* @api private
|
|
148
148
|
*/
|
|
149
149
|
|
|
150
|
-
SingleNestedPath.prototype.cast = function(val, doc, init, priorVal) {
|
|
150
|
+
SingleNestedPath.prototype.cast = function(val, doc, init, priorVal, options) {
|
|
151
151
|
if (val && val.$isSingleNested && val.parent === doc) {
|
|
152
152
|
return val;
|
|
153
153
|
}
|
|
@@ -169,16 +169,16 @@ SingleNestedPath.prototype.cast = function(val, doc, init, priorVal) {
|
|
|
169
169
|
}
|
|
170
170
|
return obj;
|
|
171
171
|
}, {});
|
|
172
|
-
|
|
172
|
+
options = Object.assign({}, options, { priorDoc: priorVal });
|
|
173
173
|
if (init) {
|
|
174
174
|
subdoc = new Constructor(void 0, selected, doc);
|
|
175
175
|
subdoc.init(val);
|
|
176
176
|
} else {
|
|
177
177
|
if (Object.keys(val).length === 0) {
|
|
178
|
-
return new Constructor({}, selected, doc, undefined,
|
|
178
|
+
return new Constructor({}, selected, doc, undefined, options);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
return new Constructor(val, selected, doc, undefined,
|
|
181
|
+
return new Constructor(val, selected, doc, undefined, options);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
return subdoc;
|
package/lib/schema/array.js
CHANGED
package/lib/schematype.js
CHANGED
|
@@ -15,8 +15,6 @@ const schemaTypeSymbol = require('./helpers/symbols').schemaTypeSymbol;
|
|
|
15
15
|
const util = require('util');
|
|
16
16
|
const utils = require('./utils');
|
|
17
17
|
const validatorErrorSymbol = require('./helpers/symbols').validatorErrorSymbol;
|
|
18
|
-
|
|
19
|
-
const documentIsSelected = require('./helpers/symbols').documentIsSelected;
|
|
20
18
|
const documentIsModified = require('./helpers/symbols').documentIsModified;
|
|
21
19
|
|
|
22
20
|
const CastError = MongooseError.CastError;
|
|
@@ -953,7 +951,7 @@ SchemaType.prototype.required = function(required, message) {
|
|
|
953
951
|
const cachedRequired = get(this, '$__.cachedRequired');
|
|
954
952
|
|
|
955
953
|
// no validation when this path wasn't selected in the query.
|
|
956
|
-
if (cachedRequired != null && !this
|
|
954
|
+
if (cachedRequired != null && !this.$__isSelected(_this.path) && !this[documentIsModified](_this.path)) {
|
|
957
955
|
return true;
|
|
958
956
|
}
|
|
959
957
|
|
package/lib/types/map.js
CHANGED
|
@@ -19,7 +19,6 @@ class MongooseMap extends Map {
|
|
|
19
19
|
v = Object.keys(v).reduce((arr, key) => arr.concat([[key, v[key]]]), []);
|
|
20
20
|
}
|
|
21
21
|
super(v);
|
|
22
|
-
|
|
23
22
|
this.$__parent = doc != null && doc.$__ != null ? doc : null;
|
|
24
23
|
this.$__path = path;
|
|
25
24
|
this.$__schemaType = schemaType == null ? new Mixed(path) : schemaType;
|
|
@@ -77,7 +76,7 @@ class MongooseMap extends Map {
|
|
|
77
76
|
} else {
|
|
78
77
|
try {
|
|
79
78
|
value = this.$__schemaType.
|
|
80
|
-
applySetters(value, this.$__parent, false, this.get(key));
|
|
79
|
+
applySetters(value, this.$__parent, false, this.get(key), { path: fullPath });
|
|
81
80
|
} catch (error) {
|
|
82
81
|
if (this.$__parent != null && this.$__parent.$__ != null) {
|
|
83
82
|
this.$__parent.invalidate(fullPath, error);
|
package/lib/types/subdocument.js
CHANGED
|
@@ -18,7 +18,9 @@ module.exports = Subdocument;
|
|
|
18
18
|
|
|
19
19
|
function Subdocument(value, fields, parent, skipId, options) {
|
|
20
20
|
this.$isSingleNested = true;
|
|
21
|
-
|
|
21
|
+
if (options != null && options.path != null) {
|
|
22
|
+
this.$basePath = options.path;
|
|
23
|
+
}
|
|
22
24
|
const hasPriorDoc = options != null && options.priorDoc;
|
|
23
25
|
let initedPaths = null;
|
|
24
26
|
if (hasPriorDoc) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "5.11.
|
|
4
|
+
"version": "5.11.14",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -120,7 +120,8 @@
|
|
|
120
120
|
],
|
|
121
121
|
"rules": {
|
|
122
122
|
"@typescript-eslint/no-explicit-any": "off",
|
|
123
|
-
"@typescript-eslint/ban-types": "off"
|
|
123
|
+
"@typescript-eslint/ban-types": "off",
|
|
124
|
+
"@typescript-eslint/no-unused-vars": "off"
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
],
|