mongoose 5.12.15 → 5.13.0
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 +12 -9
- package/index.d.ts +13 -5
- package/lib/document.js +77 -32
- package/lib/helpers/query/sanitizeProjection.js +14 -0
- package/lib/model.js +203 -8
- package/lib/query.js +22 -2
- package/lib/validoptions.js +1 -0
- package/package.json +2 -2
package/History.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
5.13.0 / 2021-06-28
|
|
2
|
+
===================
|
|
3
|
+
* feat(query): add sanitizeProjection option to opt in to automatically sanitizing untrusted query projections #10243
|
|
4
|
+
* feat(model): add `bulkSave()` function that saves multiple docs in 1 `bulkWrite()` #9727 #9673 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
5
|
+
* feat(document): allow passing a list of virtuals or `pathsToSkip` to apply in `toObject()` and `toJSON()` #10120
|
|
6
|
+
* fix(model): make Model.validate use object under validation as context by default #10360 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
7
|
+
* feat(document): add support for pathsToSkip in validate and validateSync #10375 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
8
|
+
* feat(model): add `diffIndexes()` function that calculates what indexes `syncIndexes()` will create/drop without actually executing any changes #10362 [IslandRhythms](https://github.com/IslandRhythms)
|
|
9
|
+
* feat(document): avoid using sessions that have ended, so you can use documents that were loaded in the session after calling `endSession()` #10306
|
|
10
|
+
|
|
1
11
|
5.12.15 / 2021-06-25
|
|
2
12
|
====================
|
|
3
13
|
* fix(index.d.ts): add extra TInstanceMethods generic param to `Schema` for cases when we can't infer from Model #10358
|
package/dist/browser.umd.js
CHANGED
|
@@ -304,7 +304,7 @@ Object.defineProperty(n.prototype,"_id",{enumerable:!1,configurable:!0,get:funct
|
|
|
304
304
|
/*!
|
|
305
305
|
* Module dependencies.
|
|
306
306
|
*/
|
|
307
|
-
function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){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=r.call(t)},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,u,c,l=r(19).EventEmitter,f=r(111),p=r(5),h=r(26),y=r(74),d=r(137),_=r(138),v=r(53),m=r(33),g=r(32),b=r(72),w=r(54),O=r(25),S=r(86),A=r(57).compile,$=r(57).defineKey,E=r(173).flatten,j=r(3),P=r(174),x=r(90),T=r(175),N=r(22),k=r(58),B=r(176),C=r(4).inspect,R=r(17).internalToObjectOptions,D=r(49),M=r(177),I=r(1),F=r(179),U=I.clone,L=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=r(34).schemaMixedSymbol,Z=I.specialProperties;function tt(t,e,r,n){var i=this;"object"===s(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n);var a=j(n,"defaults",!0);if(n.defaults=a,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 f,this.$__.emitter=new l,this.isNew=!("isNew"in n)||n.isNew,this.errors=void 0,this.$__.$options=n||{},this.$locals={},this.$op=null,null!=t&&"object"!==s(t))throw new d(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 p,h=c.requiredPaths(!0),y=o(h);try{for(y.s();!(p=y.n()).done;){var _=p.value;this.$__.activePaths.require(_)}}catch(t){y.e(t)}finally{y.f()}this.$__.emitter.setMaxListeners(0);var m=null;I.isPOJO(e)&&(m=B(e));var g=!1===m&&e?rt(e):{};if(null==this._doc&&(this.$__buildDoc(t,e,r,m,g,!1),a&&nt(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 tt&&(this.isNew=t.isNew)),n.willInit&&a?l.prototype.once.call(this,"init",(function(){nt(i,e,r,m,g,!1,n.skipDefaults,i.isNew)})):a&&nt(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||$(t,null,b)}))}
|
|
307
|
+
function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){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=r.call(t)},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,u,c,l=r(19).EventEmitter,f=r(111),p=r(5),h=r(26),y=r(74),d=r(137),_=r(138),v=r(53),m=r(33),g=r(32),b=r(72),w=r(54),O=r(25),S=r(86),A=r(57).compile,$=r(57).defineKey,E=r(173).flatten,j=r(3),P=r(174),x=r(90),T=r(175),N=r(22),k=r(58),B=r(176),C=r(4).inspect,R=r(17).internalToObjectOptions,D=r(49),M=r(177),I=r(1),F=r(179),U=I.clone,L=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=r(34).schemaMixedSymbol,Z=I.specialProperties;function tt(t,e,r,n){var i=this;"object"===s(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n);var a=j(n,"defaults",!0);if(n.defaults=a,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 f,this.$__.emitter=new l,this.isNew=!("isNew"in n)||n.isNew,this.errors=void 0,this.$__.$options=n||{},this.$locals={},this.$op=null,null!=t&&"object"!==s(t))throw new d(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 p,h=c.requiredPaths(!0),y=o(h);try{for(y.s();!(p=y.n()).done;){var _=p.value;this.$__.activePaths.require(_)}}catch(t){y.e(t)}finally{y.f()}this.$__.emitter.setMaxListeners(0);var m=null;I.isPOJO(e)&&(m=B(e));var g=!1===m&&e?rt(e):{};if(null==this._doc&&(this.$__buildDoc(t,e,r,m,g,!1),a&&nt(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 tt&&(this.isNew=t.isNew)),n.willInit&&a?l.prototype.once.call(this,"init",(function(){nt(i,e,r,m,g,!1,n.skipDefaults,i.isNew)})):a&&nt(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||$(t,null,b)}))}ut(this)}
|
|
308
308
|
/*!
|
|
309
309
|
* Document exposes the NodeJS event emitter API, so you can use
|
|
310
310
|
* `on`, `once`, etc.
|
|
@@ -331,24 +331,27 @@ function(t){Object.keys(t.$__.activePaths.states.require).forEach((function(e){v
|
|
|
331
331
|
* ignore
|
|
332
332
|
*/
|
|
333
333
|
function st(t,e){var r,n=new Set(e),i=new Map([]),s=o(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)i.set(c,a),c=c+"."+u[l]}}catch(t){s.e(t)}finally{s.f()}var f,p=[],h=o(t);try{for(h.s();!(f=h.n()).done;){var y=f.value;n.has(y)?p.push(y):i.has(y)&&p.push(i.get(y))}}catch(t){h.e(t)}finally{h.f()}return p}
|
|
334
|
+
/*!
|
|
335
|
+
* ignore
|
|
336
|
+
*/function at(t,e){return e=new Set(e),t=t.filter((function(t){return!e.has(t)}))}
|
|
334
337
|
/*!
|
|
335
338
|
* Runs queued functions
|
|
336
339
|
*/
|
|
337
|
-
function
|
|
340
|
+
function ut(t){var e=t.$__schema&&t.$__schema.callQueue;if(e.length){var r,n=o(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;"pre"!==i[0]&&"post"!==i[0]&&"on"!==i[0]&&t[i[0]].apply(t,i[1])}}catch(t){n.e(t)}finally{n.f()}}}
|
|
338
341
|
/*!
|
|
339
342
|
* ignore
|
|
340
343
|
*/
|
|
341
344
|
/*!
|
|
342
345
|
* Applies virtuals properties to `json`.
|
|
343
346
|
*/
|
|
344
|
-
function
|
|
347
|
+
function ct(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=j(n,"aliases",!0),h=null;if(Array.isArray(r.virtuals))h=new Set(r.virtuals);else if(r.virtuals&&r.virtuals.pathsToSkip){h=new Set(u);for(var y=0;y<r.virtuals.pathsToSkip.length;y++)h.has(r.virtuals.pathsToSkip[y])&&h.delete(r.virtuals.pathsToSkip[y])}if(!f)return e;for(r=r||{},c=0;c<l;++c)if(o=u[c],(null==h||h.has(o))&&(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 d=i.split(".");if(void 0!==(s=U(t.get(o),r))){var _=d.length;f=e;for(var v=0;v<_-1;++v)f[d[v]]=f[d[v]]||{},f=f[d[v]];f[d[_-1]]=s}}return e}
|
|
345
348
|
/*!
|
|
346
349
|
* Applies virtuals properties to `json`.
|
|
347
350
|
*
|
|
348
351
|
* @param {Document} self
|
|
349
352
|
* @param {Object} json
|
|
350
353
|
* @return {Object} `json`
|
|
351
|
-
*/function
|
|
354
|
+
*/function lt(t,e){if(F(e))throw new Error("`transform` function must be synchronous, but the transform on path `"+t+"` returned a promise.")}
|
|
352
355
|
/*!
|
|
353
356
|
* ignore
|
|
354
357
|
*/tt.prototype.$__schema,tt.prototype.schema,Object.defineProperty(tt.prototype,"$locals",{configurable:!1,enumerable:!1,writable:!0}),tt.prototype.isNew,tt.prototype.id,tt.prototype.errors,tt.prototype.$op,tt.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=this.$__schema.paths[c].splitPath(),f=l.length,p=f-1,h="",y=i,d=!1,_=0;_<f;++_){var v=l[_];if(h+=(h.length?".":"")+v,!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[v]||(y[v]={}))}}this._doc=i},
|
|
@@ -377,22 +380,22 @@ return function t(e,r,n,o,i){i=i||"";var s,a,u,c=Object.keys(r),l=c.length,f=0;f
|
|
|
377
380
|
* const doc = await Article.findOne().populate('comments.author');
|
|
378
381
|
* doc.comments[0].populated('author'); // Should be set
|
|
379
382
|
*/
|
|
380
|
-
function(t,e){if(null==t._id||null==e||0===e.length)return;var r,n=String(t._id),i=o(e);try{for(i.s();!(r=i.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){i.e(t)}finally{i.f()}}(this,e.populated),this.emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},tt.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},tt.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},tt.prototype.replaceOne=function(){var t=I.args(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},tt.prototype.$session=function(t){if(0===arguments.length)return this.$__.session;if(this.$__.session=t,!this.ownerDocument){var e,r=this.$getAllSubdocs(),n=o(r);try{for(n.s();!(e=n.n()).done;){var i=e.value;i.$session(t)}}catch(t){n.e(t)}finally{n.f()}}return t},tt.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},tt.prototype.$set=function(t,e,r,i){var a=this;I.isPOJO(r)&&(i=r,r=void 0);var u,c,l,f,d=(i=i||{}).merge,_=r&&!0!==r,v=!0===r,g=
|
|
383
|
+
function(t,e){if(null==t._id||null==e||0===e.length)return;var r,n=String(t._id),i=o(e);try{for(i.s();!(r=i.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){i.e(t)}finally{i.f()}}(this,e.populated),this.emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},tt.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},tt.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},tt.prototype.replaceOne=function(){var t=I.args(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},tt.prototype.$session=function(t){if(0===arguments.length)return null!=this.$__.session&&this.$__.session.hasEnded?(this.$__.session=null,null):this.$__.session;if(null!=t&&t.hasEnded)throw new p("Cannot set a document's session to a session that has ended. Make sure you haven't called `endSession()` on the session you are passing to `$session()`.");if(this.$__.session=t,!this.ownerDocument){var e,r=this.$getAllSubdocs(),n=o(r);try{for(n.s();!(e=n.n()).done;){var i=e.value;i.$session(t)}}catch(t){n.e(t)}finally{n.f()}}return t},tt.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},tt.prototype.$set=function(t,e,r,i){var a=this;I.isPOJO(r)&&(i=r,r=void 0);var u,c,l,f,d=(i=i||{}).merge,_=r&&!0!==r,v=!0===r,g=this.$__schema.options.typeKey,b=0,w="strict"in i?i.strict:this.$__.strictMode;if(_&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var O=t;t=e,e=O}else{if("string"!=typeof t){if(t instanceof tt&&(t=t.$__isNested?t.toObject():t._doc),null==t){var A=t;t=e,e=A}f=e?e+".":"";var $=(u=Object.keys(t)).length,E=j(i,"_skipMinimizeTopLevel",!1);if(0===$&&E)return delete i._skipMinimizeTopLevel,e&&this.$set(e,{}),this;for(var T=0;T<$;++T){var N=f+(l=u[T]);if(c=this.$__schema.pathType(N),!0!==r||f||null==t[l]||"nested"!==c||null==this._doc[l]||0!==Object.keys(this._doc[l]).length||(delete this._doc[l],i=Object.assign({},i,{_skipMinimizeTopLevel:!0})),!("object"!==s(t[l])||I.isNativeObject(t[l])||I.isMongooseType(t[l])||null==t[l]||"virtual"===c||"real"===c||"adhocOrUndefined"===c||this.$__path(N)instanceof h||this.$__schema.paths[N]&&this.$__schema.paths[N].options&&this.$__schema.paths[N].options.ref))this.$__.$setCalled.add(f+l),this.$set(t[l],f+l,v,i);else if(w){if(v&&void 0===t[l]&&void 0!==this.get(N))continue;if("adhocOrUndefined"===c&&(c=P(this,N,{typeOnly:!0})),"real"===c||"virtual"===c){var k=t[l];this.$__schema.paths[N]&&this.$__schema.paths[N].$isSingleNested&&t[l]instanceof tt&&(k=k.toObject({virtuals:!1,transform:!1})),this.$set(f+l,k,v,i)}else if("nested"===c&&t[l]instanceof tt)this.$set(f+l,t[l].toObject({transform:!1}),v,i);else if("throw"===w)throw"nested"===c?new y(l,t[l]):new m(l)}else void 0!==t[l]&&this.$set(f+l,t[l],v,i)}return this}this.$__.$setCalled.add(t)}var B,C=this.$__schema.pathType(t);if("adhocOrUndefined"===C&&(C=P(this,t,{typeOnly:!0})),e=x(e),"nested"===C&&e){if("object"===s(e)&&null!=e){var R=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.isNew&&!this.$__.savedState.hasOwnProperty(t)){var M=this.$__getValue(t);this.$__.savedState[t]=M;for(var F=0,U=Object.keys(M||{});F<U.length;F++){var L=U[F];this.$__.savedState[t+"."+L]=M[L]}}if(d)return this.$set(e,t,v);this.$__setValue(t,null),S(this,t);var V=Object.keys(e);this.$__setValue(t,{});for(var q=0,W=V;q<W.length;q++){var H=W[q];this.$set(t+"."+H,e[H],v)}return R&&I.deepEqual(this.$__.savedState[t],e)?this.unmarkModified(t):this.markModified(t),S(this,t,{skipDocArrays:!0}),this}return this.invalidate(t,new p.CastError("Object",e,t)),this}var Y=-1===t.indexOf(".")?[t]:t.split(".");if("string"==typeof this.$__schema.aliases[Y[0]]&&(Y[0]=this.$__schema.aliases[Y[0]]),"adhocOrUndefined"===C&&w){var K;for(b=0;b<Y.length;++b){var z=Y.slice(0,b+1).join(".");if(b+1<Y.length&&"virtual"===this.$__schema.pathType(z))return D.set(t,e,this),this;if(null!=(B=this.$__schema.path(z))&&B instanceof h){K=!0;break}}if(null==B&&(B=P(this,t)),!K&&!B){if("throw"===w)throw new m(t);return this}}else{if("virtual"===C)return(B=this.$__schema.virtualpath(t)).applySetters(e,this),this;B=this.$__path(t)}var Q,G=this._doc,X="";for(b=0;b<Y.length-1;++b)G=G[Y[b]],X+=(X.length>0?".":"")+Y[b],G||(this.$set(X,{}),this.$__isSelected(X)||this.unmarkModified(X),G=this.$__getValue(X));if(Y.length<=1)Q=t;else{for(b=0;b<Y.length;++b){var Z=Y.slice(0,b+1).join(".");if(null===this.get(Z,null,{getters:!1})){Q=Z;break}}Q||(Q=t)}var et=null!=a.$__.$options.priorDoc?a.$__.$options.priorDoc.$__getValue(t):v?void 0:a.$__getValue(t);if(!B)return this.$__set(Q,t,v,Y,B,e,et),this;if((B.$isSingleNested||B.$isMongooseArray)&&
|
|
381
384
|
/*!
|
|
382
385
|
* ignore
|
|
383
386
|
*/
|
|
384
387
|
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)}
|
|
385
388
|
/*!
|
|
386
389
|
* ignore
|
|
387
|
-
*/(this,t),
|
|
390
|
+
*/(this,t),B.$isSingleNested&&null!=e&&d){e instanceof tt&&(e=e.toObject({virtuals:!1,transform:!1}));for(var rt=0,nt=Object.keys(e);rt<nt.length;rt++){var ot=nt[rt];this.$set(t+"."+ot,e[ot],v,i)}return this}var it=!0;try{var st,at=function(){if(null==B.options)return!1;if(!(e instanceof tt))return!1;var t=e.constructor,r=B.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=B.options.refPath;if(null==n)return!1;var o=e.get(n);return o===t.modelName||o===t.baseModelName}(),ut=!1;if(at&&e instanceof tt&&(this.populated(t,e._id,n({},J,e.constructor)),e.$__.wasPopulated=!0,ut=!0),B.options&&Array.isArray(B.options[g])&&B.options[g].length&&B.options[g][0].ref&&
|
|
388
391
|
/*!
|
|
389
392
|
* ignore
|
|
390
393
|
*/
|
|
391
|
-
function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=o(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof tt))return!1;if(null==i.constructor.modelName)return!1;if(i.constructor.modelName!=e&&i.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,
|
|
394
|
+
function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=o(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof tt))return!1;if(null==i.constructor.modelName)return!1;if(i.constructor.modelName!=e&&i.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,B.options[g][0].ref)){st=n({},J,e[0].constructor),this.populated(t,e.map((function(t){return t._id})),st);var ct,lt=o(e);try{for(lt.s();!(ct=lt.n()).done;){ct.value.$__.wasPopulated=!0}}catch(t){lt.e(t)}finally{lt.f()}ut=!0}if(null==this.$__schema.singleNestedPaths[t]&&(e=B.applySetters(e,this,!1,et)),B.$isMongooseDocumentArray&&Array.isArray(e)&&e.length>0&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var ft=Object.keys(e[0].$__.populated),pt=function(){var r=yt[ht];a.populated(t+"."+r,e.map((function(t){return t.populated(r)})),e[0].$__.populated[r].options)},ht=0,yt=ft;ht<yt.length;ht++)pt();ut=!0}if(!ut&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var dt=0;dt<e.length;++dt)e[dt]instanceof tt&&(e[dt]=e[dt]._id);delete this.$__.populated[t]}B.$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,B,et),this.$markValid(t)}catch(r){r instanceof p.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof p.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new p.CastError(B.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new p.CastError(B.instance,e,t,r)),it=!1}return it&&(this.$__set(Q,t,v,Y,B,e,et),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]=et)),B.$isSingleNested&&(this.isDirectModified(t)||null==e)&&S(this,t),this},tt.prototype.set=tt.prototype.$set,tt.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 tt&&L(i._id,s))&&(!L(i,s||I.getValue(e,this))||!(r||null==i||!(e in this.$__.activePaths.states.default)||!L(i,o.getDefault(this,r))))))},tt.prototype.$__set=function(t,e,n,o,i,s,a){c=c||r(27);var l=this.$__shouldModify(t,e,n,o,i,s,a),f=this;l&&(this.markModified(t),u||(u=r(84)),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],Z.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 c||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]])}},tt.prototype.$__getValue=function(t){return I.getValue(t,this._doc)},tt.prototype.$__setValue=function(t,e){return I.setValue(t,e,this._doc),this},tt.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 h){var i=this.$__schema.virtualpath(t);null!=i&&(o=i)}var s=-1===t.indexOf(".")?[t]:t.split("."),a=this._doc;if(o instanceof w)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 ct(this,I.clone(a)||{},{path:t});return a},
|
|
392
395
|
/*!
|
|
393
396
|
* ignore
|
|
394
397
|
*/
|
|
395
|
-
tt.prototype[Q]=tt.prototype.get,tt.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e.hasOwnProperty(t)?e[t]:null;return r||this.$__schema.path(t)},tt.prototype.markModified=function(t,e){this.$__.activePaths.modify(t),null==e||this.ownerDocument||(this.$__.pathsToScopes[t]=e)},tt.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),delete this.$__.pathsToScopes[t]},tt.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},tt.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.states.modify)},tt.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"===s(r)&&(I.isPOJO(r)?ot(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},tt.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.states.modify),r=this;return e.reduce((function(e,n){var i=n.split(".");if(e=e.concat(i.reduce((function(t,e,r){return t.concat(i.slice(0,r).concat(e).join("."))}),[]).filter((function(t){return-1===e.indexOf(t)}))),!t.includeChildren)return e;var a=r.get(n);if(null!=a&&"object"===s(a))if(a._doc&&(a=a._doc),Array.isArray(a)){for(var u=a.length,c=0;c<u;++c)if(-1===e.indexOf(n+"."+c)&&(e.push(n+"."+c),null!=a[c]&&a[c].$__)){var l,f=o(a[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(a).filter((function(t){return-1===e.indexOf(n+"."+t)})).forEach((function(t){e.push(n+"."+t)}));return e}),[])},tt.prototype[K]=tt.prototype.modifiedPaths,tt.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")},tt.prototype[Y]=tt.prototype.isModified,tt.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)}))},tt.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},tt.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)}))},tt.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)}))},tt.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},tt.prototype.$__isSelected=tt.prototype.isSelected,tt.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)},tt.prototype.validate=function(t,e,r){var n,o=this;return this.$op="validate",null!=this.ownerDocument||(this.$__.validating?n=new _(this,{parentStack:e&&e.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new _(this,{parentStack:e&&e.parentStack})),1===arguments.length?"object"!==s(arguments[0])||Array.isArray(arguments[0])?"function"==typeof arguments[0]&&(r=arguments[0],e=null,t=null):(e=arguments[0],r=null,t=null):"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=t,t=null),O(r,(function(r){if(null!=n)return r(n);o.$__validate(t,e,(function(t){o.$op=null,r(t)}))}),this.constructor.events)},tt.prototype.$__validate=function(t,e,r){var n=this;"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=null);var o,i=e&&"object"===s(e)&&"validateModifiedOnly"in e;o=i?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var a=this,u=function(){var t=n.$__.validationError;if(n.$__.validationError=void 0,o&&null!=t){for(var e=0,r=Object.keys(t.errors);e<r.length;e++){var i=r[e];n.isModified(i)||delete t.errors[i]}0===Object.keys(t.errors).length&&(t=void 0)}if(n.$__.cachedRequired={},n.emit("validate",a),n.constructor.emit("validate",a),n.$__.validating=null,t){for(var s in t.errors)!n[H]&&t.errors[s]instanceof p.CastError&&n.invalidate(s,t.errors[s]);return t}},c=it(this),l=o?c[0].filter((function(t){return n.isModified(t)})):c[0],f=c[1];if("string"==typeof t&&(t=t.split(" ")),Array.isArray(t)&&(l=st(l,t)),0===l.length)return N((function(){var t=u();if(t)return a.$__schema.s.hooks.execPost("validate:error",a,[a],{error:t},(function(t){r(t)}));r(null,a)}));for(var h={},y=0,d=function(){var t=u();if(t)return a.$__schema.s.hooks.execPost("validate:error",a,[a],{error:t},(function(t){r(t)}));r(null,a)},_=function(t){null==t||h[t]||(h[t]=!0,y++,N((function(){var e=a.$__schema.path(t);if(!e)return--y||d();if(a.$isValid(t)){if(null!=e[X]&&t!==e.path)return--y||d();var r,n=a.$__getValue(t);null==n&&(r=a.populated(t))&&(n=r);var i=t in a.$__.pathsToScopes?a.$__.pathsToScopes[t]:a,s={skipSchemaValidators:f[t],path:t,validateModifiedOnly:o};e.doValidate(n,(function(r){if(r&&(!e.$isMongooseDocumentArray||r.$isArrayValidatorError)){if(e.$isSingleNested&&r instanceof g&&!1===e.schema.options.storeSubdocValidationError)return--y||d();a.invalidate(t,r,void 0,!0)}--y||d()}),i,s)}else--y||d()})))},v=l.length,m=0;m<v;++m)_(l[m])},tt.prototype.validateSync=function(t,e){var r=this,n=this;1!==arguments.length||"object"!==s(arguments[0])||Array.isArray(arguments[0])||(e=arguments[0],t=null);var o,i=e&&"object"===s(e)&&"validateModifiedOnly"in e;o=i?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly,"string"==typeof t&&(t=t.split(" "));var a=it(this),u=o?a[0].filter((function(t){return r.isModified(t)})):a[0],c=a[1];"string"==typeof t&&(t=t.split(" ")),Array.isArray(t)&&(u=st(u,t));var l={};u.forEach((function(t){if(!l[t]){l[t]=!0;var e=n.$__schema.path(t);if(e&&n.$isValid(t)){var r=n.$__getValue(t),i=e.doValidateSync(r,n,{skipSchemaValidators:c[t],path:t,validateModifiedOnly:o});if(i&&(!e.$isMongooseDocumentArray||i.$isArrayValidatorError)){if(e.$isSingleNested&&i instanceof g&&!1===e.schema.options.storeSubdocValidationError)return;n.invalidate(t,i,void 0,!0)}}}}));var f=n.$__.validationError;if(n.$__.validationError=void 0,n.emit("validate",n),n.constructor.emit("validate",n),f)for(var h in f.errors)f.errors[h]instanceof p.CastError&&n.invalidate(h,f.errors[h]);return f},tt.prototype.invalidate=function(t,e,r,n){if(this.$__.validationError||(this.$__.validationError=new g(this)),!this.$__.validationError.errors[t])return e&&"string"!=typeof e||(e=new b({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e||this.$__.validationError.addError(t,e),this.$__.validationError},tt.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))},tt.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])},tt.prototype.$__reset=function(){var t=this;return a||(a=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(),e.$__parent===t?t.$__.activePaths.init(e.$basePath):null!=e.$__parent&&e.$__parent.ownerDocument&&e.$__parent.$__reset()})),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},
|
|
398
|
+
tt.prototype[Q]=tt.prototype.get,tt.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e.hasOwnProperty(t)?e[t]:null;return r||this.$__schema.path(t)},tt.prototype.markModified=function(t,e){this.$__.activePaths.modify(t),null==e||this.ownerDocument||(this.$__.pathsToScopes[t]=e)},tt.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),delete this.$__.pathsToScopes[t]},tt.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},tt.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.states.modify)},tt.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"===s(r)&&(I.isPOJO(r)?ot(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},tt.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.states.modify),r=this;return e.reduce((function(e,n){var i=n.split(".");if(e=e.concat(i.reduce((function(t,e,r){return t.concat(i.slice(0,r).concat(e).join("."))}),[]).filter((function(t){return-1===e.indexOf(t)}))),!t.includeChildren)return e;var a=r.get(n);if(null!=a&&"object"===s(a))if(a._doc&&(a=a._doc),Array.isArray(a)){for(var u=a.length,c=0;c<u;++c)if(-1===e.indexOf(n+"."+c)&&(e.push(n+"."+c),null!=a[c]&&a[c].$__)){var l,f=o(a[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(a).filter((function(t){return-1===e.indexOf(n+"."+t)})).forEach((function(t){e.push(n+"."+t)}));return e}),[])},tt.prototype[K]=tt.prototype.modifiedPaths,tt.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")},tt.prototype[Y]=tt.prototype.isModified,tt.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)}))},tt.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},tt.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)}))},tt.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)}))},tt.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},tt.prototype.$__isSelected=tt.prototype.isSelected,tt.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)},tt.prototype.validate=function(t,e,r){var n,o=this;if(this.$op="validate",null!=this.ownerDocument||(this.$__.validating?n=new _(this,{parentStack:e&&e.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new _(this,{parentStack:e&&e.parentStack})),1===arguments.length?"object"!==s(arguments[0])||Array.isArray(arguments[0])?"function"==typeof arguments[0]&&(r=arguments[0],e=null,t=null):(e=arguments[0],r=null,t=null):"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=t,t=null),e&&"string"==typeof e.pathsToSkip){var i=-1===e.pathsToSkip.indexOf(" ");e.pathsToSkip=i?[e.pathsToSkip]:e.pathsToSkip.split(" ")}return O(r,(function(r){if(null!=n)return r(n);o.$__validate(t,e,(function(t){o.$op=null,r(t)}))}),this.constructor.events)},tt.prototype.$__validate=function(t,e,r){var n=this;"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=null);var i,a=e&&"object"===s(e)&&"validateModifiedOnly"in e,u=j(e,"pathsToSkip",null);i=a?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var c=this,l=function(){var t=n.$__.validationError;if(n.$__.validationError=void 0,i&&null!=t){for(var e=0,r=Object.keys(t.errors);e<r.length;e++){var o=r[e];n.isModified(o)||delete t.errors[o]}0===Object.keys(t.errors).length&&(t=void 0)}if(n.$__.cachedRequired={},n.emit("validate",c),n.constructor.emit("validate",c),n.$__.validating=null,t){for(var s in t.errors)!n[H]&&t.errors[s]instanceof p.CastError&&n.invalidate(s,t.errors[s]);return t}},f=it(this),h=i?f[0].filter((function(t){return n.isModified(t)})):f[0],y=f[1];if("string"==typeof t&&(t=t.split(" ")),Array.isArray(t)?h=st(h,t):u&&(h=at(h,u)),0===h.length)return N((function(){var t=l();if(t)return c.$__schema.s.hooks.execPost("validate:error",c,[c],{error:t},(function(t){r(t)}));r(null,c)}));var d,_={},v=0,m=o(h);try{for(m.s();!(d=m.n()).done;){b(d.value)}}catch(t){m.e(t)}finally{m.f()}function b(t){null==t||_[t]||(_[t]=!0,v++,N((function(){var e=c.$__schema.path(t);if(!e)return--v||w();if(c.$isValid(t)){if(null!=e[X]&&t!==e.path)return--v||w();var r,n=c.$__getValue(t);null==n&&(r=c.populated(t))&&(n=r);var o=t in c.$__.pathsToScopes?c.$__.pathsToScopes[t]:c,s={skipSchemaValidators:y[t],path:t,validateModifiedOnly:i};e.doValidate(n,(function(r){if(r&&(!e.$isMongooseDocumentArray||r.$isArrayValidatorError)){if(e.$isSingleNested&&r instanceof g&&!1===e.schema.options.storeSubdocValidationError)return--v||w();c.invalidate(t,r,void 0,!0)}--v||w()}),o,s)}else--v||w()})))}function w(){var t=l();if(t)return c.$__schema.s.hooks.execPost("validate:error",c,[c],{error:t},(function(t){r(t)}));r(null,c)}},tt.prototype.validateSync=function(t,e){var r=this,n=this;1!==arguments.length||"object"!==s(arguments[0])||Array.isArray(arguments[0])||(e=arguments[0],t=null);var o,i=e&&"object"===s(e)&&"validateModifiedOnly"in e;o=i?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var a=e&&e.pathsToSkip;if("string"==typeof t){var u=-1===t.indexOf(" ");t=u?[t]:t.split(" ")}else"string"==typeof a&&-1!==a.indexOf(" ")&&(a=a.split(" "));var c=it(this),l=o?c[0].filter((function(t){return r.isModified(t)})):c[0],f=c[1];Array.isArray(t)?l=st(l,t):Array.isArray(a)&&(l=at(l,a));var h={};l.forEach((function(t){if(!h[t]){h[t]=!0;var e=n.$__schema.path(t);if(e&&n.$isValid(t)){var r=n.$__getValue(t),i=e.doValidateSync(r,n,{skipSchemaValidators:f[t],path:t,validateModifiedOnly:o});if(i&&(!e.$isMongooseDocumentArray||i.$isArrayValidatorError)){if(e.$isSingleNested&&i instanceof g&&!1===e.schema.options.storeSubdocValidationError)return;n.invalidate(t,i,void 0,!0)}}}}));var y=n.$__.validationError;if(n.$__.validationError=void 0,n.emit("validate",n),n.constructor.emit("validate",n),y)for(var d in y.errors)y.errors[d]instanceof p.CastError&&n.invalidate(d,y.errors[d]);return y},tt.prototype.invalidate=function(t,e,r,n){if(this.$__.validationError||(this.$__.validationError=new g(this)),!this.$__.validationError.errors[t])return e&&"string"!=typeof e||(e=new b({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e||this.$__.validationError.addError(t,e),this.$__.validationError},tt.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))},tt.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])},tt.prototype.$__reset=function(){var t=this;return a||(a=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(),e.$__parent===t?t.$__.activePaths.init(e.$basePath):null!=e.$__parent&&e.$__parent.ownerDocument&&e.$__parent.$__reset()})),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},
|
|
396
399
|
/*!
|
|
397
400
|
* ignore
|
|
398
401
|
*/
|
|
@@ -410,7 +413,7 @@ tt.prototype.$__undoReset=function(){if(null!=this.$__.backup&&null!=this.$__.ba
|
|
|
410
413
|
* @param {Object} object to minimize
|
|
411
414
|
* @return {Object}
|
|
412
415
|
*/
|
|
413
|
-
function t(r){var n,o,i,s=Object.keys(r),a=s.length;for(;a--;)o=s[a],i=r[o],I.isObject(i)&&!e.isBuffer(i)&&(r[o]=t(i)),void 0!==r[o]?n=!0:delete r[o];return n?r:void 0}(p)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&
|
|
416
|
+
function t(r){var n,o,i,s=Object.keys(r),a=s.length;for(;a--;)o=s[a],i=r[o],I.isObject(i)&&!e.isBuffer(i)&&(r[o]=t(i)),void 0!==r[o]?n=!0:delete r[o];return n?r:void 0}(p)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&ct(this,p,l,t),!1===t.versionKey&&this.$__schema.options.versionKey&&delete p[this.$__schema.options.versionKey];var h=t.transform;if(h&&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);lt(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,lt(s,h)}e[s]=l}}}(this,p),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,p),!0===h||u.toObject&&h){var y=t.json?u.toJSON:u.toObject;y&&(h="function"==typeof t.transform?t.transform:y.transform)}else t.transform=f;if("function"==typeof h){var d=h(this,p,t);void 0!==d&&(p=d)}return p},tt.prototype.toObject=function(t){return this.$toObject(t)},tt.prototype.toJSON=function(t){return this.$toObject(t,!0)},tt.prototype.parent=function(){return this.$__.parent},tt.prototype.$parent=tt.prototype.parent,tt.prototype.inspect=function(t){var e;I.isPOJO(t)&&((e=t).minimize=!1);var r=this.toObject(e);return null==r?"MongooseDocument { "+r+" }":r},C.custom&&(
|
|
414
417
|
/*!
|
|
415
418
|
* Avoid Node deprecation warning DEP0079
|
|
416
419
|
*/
|
package/index.d.ts
CHANGED
|
@@ -599,15 +599,22 @@ declare module 'mongoose' {
|
|
|
599
599
|
updateOne(update?: UpdateQuery<this> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: (err: CallbackError, res: any) => void): Query<any, this>;
|
|
600
600
|
|
|
601
601
|
/** Executes registered validation rules for this document. */
|
|
602
|
-
validate(
|
|
602
|
+
validate(options:{ pathsToSkip?: pathsToSkip }): Promise<void>;
|
|
603
|
+
validate(pathsToValidate?: pathsToValidate, options?: any): Promise<void>;
|
|
603
604
|
validate(callback: (err: CallbackError) => void): void;
|
|
604
|
-
validate(pathsToValidate:
|
|
605
|
-
validate(pathsToValidate:
|
|
605
|
+
validate(pathsToValidate: pathsToValidate, callback: (err: CallbackError) => void): void;
|
|
606
|
+
validate(pathsToValidate: pathsToValidate, options: any, callback: (err: CallbackError) => void): void;
|
|
606
607
|
|
|
607
608
|
/** Executes registered validation rules (skipping asynchronous validators) for this document. */
|
|
609
|
+
validateSync(options:{pathsToSkip?: pathsToSkip, [k:string]: any }): Error.ValidationError | null;
|
|
608
610
|
validateSync(pathsToValidate?: Array<string>, options?: any): Error.ValidationError | null;
|
|
609
611
|
}
|
|
610
612
|
|
|
613
|
+
/** A list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. */
|
|
614
|
+
type pathsToValidate = string[] | string;
|
|
615
|
+
/** A list of paths to skip. If set, Mongoose will validate every modified path that is not in this list. */
|
|
616
|
+
type pathsToSkip = string[] | string;
|
|
617
|
+
|
|
611
618
|
interface AcceptsDiscriminator {
|
|
612
619
|
/** Adds a discriminator type. */
|
|
613
620
|
discriminator<D extends Document>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<D>;
|
|
@@ -931,6 +938,7 @@ declare module 'mongoose' {
|
|
|
931
938
|
*/
|
|
932
939
|
returnDocument?: string;
|
|
933
940
|
runValidators?: boolean;
|
|
941
|
+
sanitizeProjection?: boolean;
|
|
934
942
|
/** The session associated with this query. */
|
|
935
943
|
session?: mongodb.ClientSession;
|
|
936
944
|
setDefaultsOnInsert?: boolean;
|
|
@@ -951,7 +959,7 @@ declare module 'mongoose' {
|
|
|
951
959
|
writeConcern?: any;
|
|
952
960
|
}
|
|
953
961
|
|
|
954
|
-
type MongooseQueryOptions = Pick<QueryOptions, 'populate' | 'lean' | 'omitUndefined' | 'strict' | 'useFindAndModify'>;
|
|
962
|
+
type MongooseQueryOptions = Pick<QueryOptions, 'populate' | 'lean' | 'omitUndefined' | 'strict' | 'useFindAndModify' | 'sanitizeProjection'>;
|
|
955
963
|
|
|
956
964
|
interface SaveOptions {
|
|
957
965
|
checkKeys?: boolean;
|
|
@@ -1068,7 +1076,7 @@ declare module 'mongoose' {
|
|
|
1068
1076
|
/** apply all getters (path and virtual getters) */
|
|
1069
1077
|
getters?: boolean;
|
|
1070
1078
|
/** apply virtual getters (can override getters option) */
|
|
1071
|
-
virtuals?: boolean;
|
|
1079
|
+
virtuals?: boolean | string[];
|
|
1072
1080
|
/** if `options.virtuals = true`, you can set `options.aliases = false` to skip applying aliases. This option is a no-op if `options.virtuals = false`. */
|
|
1073
1081
|
aliases?: boolean;
|
|
1074
1082
|
/** remove empty objects (defaults to true) */
|
package/lib/document.js
CHANGED
|
@@ -846,8 +846,18 @@ Document.prototype.replaceOne = function replaceOne() {
|
|
|
846
846
|
|
|
847
847
|
Document.prototype.$session = function $session(session) {
|
|
848
848
|
if (arguments.length === 0) {
|
|
849
|
+
if (this.$__.session != null && this.$__.session.hasEnded) {
|
|
850
|
+
this.$__.session = null;
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
849
853
|
return this.$__.session;
|
|
850
854
|
}
|
|
855
|
+
|
|
856
|
+
if (session != null && session.hasEnded) {
|
|
857
|
+
throw new MongooseError('Cannot set a document\'s session to a session that has ended. Make sure you haven\'t ' +
|
|
858
|
+
'called `endSession()` on the session you are passing to `$session()`.');
|
|
859
|
+
}
|
|
860
|
+
|
|
851
861
|
this.$__.session = session;
|
|
852
862
|
|
|
853
863
|
if (!this.ownerDocument) {
|
|
@@ -908,7 +918,6 @@ Document.prototype.overwrite = function overwrite(obj) {
|
|
|
908
918
|
*/
|
|
909
919
|
|
|
910
920
|
Document.prototype.$set = function $set(path, val, type, options) {
|
|
911
|
-
|
|
912
921
|
if (utils.isPOJO(type)) {
|
|
913
922
|
options = type;
|
|
914
923
|
type = undefined;
|
|
@@ -918,6 +927,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
|
|
|
918
927
|
const merge = options.merge;
|
|
919
928
|
const adhoc = type && type !== true;
|
|
920
929
|
const constructing = type === true;
|
|
930
|
+
const typeKey = this.$__schema.options.typeKey;
|
|
921
931
|
let adhocs;
|
|
922
932
|
let keys;
|
|
923
933
|
let i = 0;
|
|
@@ -1253,18 +1263,13 @@ Document.prototype.$set = function $set(path, val, type, options) {
|
|
|
1253
1263
|
|
|
1254
1264
|
let popOpts;
|
|
1255
1265
|
if (schema.options &&
|
|
1256
|
-
Array.isArray(schema.options[
|
|
1257
|
-
schema.options[
|
|
1258
|
-
schema.options[
|
|
1259
|
-
_isManuallyPopulatedArray(val, schema.options[
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
val.map(function(v) { return v._id; }), popOpts);
|
|
1264
|
-
} else {
|
|
1265
|
-
popOpts = { [populateModelSymbol]: val[0].constructor };
|
|
1266
|
-
this.populated(path, val.map(function(v) { return v._id; }), popOpts);
|
|
1267
|
-
}
|
|
1266
|
+
Array.isArray(schema.options[typeKey]) &&
|
|
1267
|
+
schema.options[typeKey].length &&
|
|
1268
|
+
schema.options[typeKey][0].ref &&
|
|
1269
|
+
_isManuallyPopulatedArray(val, schema.options[typeKey][0].ref)) {
|
|
1270
|
+
popOpts = { [populateModelSymbol]: val[0].constructor };
|
|
1271
|
+
this.populated(path, val.map(function(v) { return v._id; }), popOpts);
|
|
1272
|
+
|
|
1268
1273
|
for (const doc of val) {
|
|
1269
1274
|
doc.$__.wasPopulated = true;
|
|
1270
1275
|
}
|
|
@@ -2206,6 +2211,7 @@ Document.prototype.isDirectSelected = function isDirectSelected(path) {
|
|
|
2206
2211
|
* @param {Array|String} [pathsToValidate] list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list.
|
|
2207
2212
|
* @param {Object} [options] internal options
|
|
2208
2213
|
* @param {Boolean} [options.validateModifiedOnly=false] if `true` mongoose validates only modified paths.
|
|
2214
|
+
* @param {Array|string} [options.pathsToSkip] list of paths to skip. If set, Mongoose will validate every modified path that is not in this list.
|
|
2209
2215
|
* @param {Function} [callback] optional callback called after validation completes, passing an error if one occurred
|
|
2210
2216
|
* @return {Promise} Promise
|
|
2211
2217
|
* @api public
|
|
@@ -2245,6 +2251,10 @@ Document.prototype.validate = function(pathsToValidate, options, callback) {
|
|
|
2245
2251
|
options = pathsToValidate;
|
|
2246
2252
|
pathsToValidate = null;
|
|
2247
2253
|
}
|
|
2254
|
+
if (options && typeof options.pathsToSkip === 'string') {
|
|
2255
|
+
const isOnePathOnly = options.pathsToSkip.indexOf(' ') === -1;
|
|
2256
|
+
options.pathsToSkip = isOnePathOnly ? [options.pathsToSkip] : options.pathsToSkip.split(' ');
|
|
2257
|
+
}
|
|
2248
2258
|
|
|
2249
2259
|
return promiseOrCallback(callback, cb => {
|
|
2250
2260
|
if (parallelValidate != null) {
|
|
@@ -2407,6 +2417,8 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2407
2417
|
(typeof options === 'object') &&
|
|
2408
2418
|
('validateModifiedOnly' in options);
|
|
2409
2419
|
|
|
2420
|
+
const pathsToSkip = get(options, 'pathsToSkip', null);
|
|
2421
|
+
|
|
2410
2422
|
let shouldValidateModifiedOnly;
|
|
2411
2423
|
if (hasValidateModifiedOnlyOption) {
|
|
2412
2424
|
shouldValidateModifiedOnly = !!options.validateModifiedOnly;
|
|
@@ -2456,12 +2468,13 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2456
2468
|
pathDetails[0].filter((path) => this.isModified(path)) :
|
|
2457
2469
|
pathDetails[0];
|
|
2458
2470
|
const skipSchemaValidators = pathDetails[1];
|
|
2459
|
-
|
|
2460
2471
|
if (typeof pathsToValidate === 'string') {
|
|
2461
2472
|
pathsToValidate = pathsToValidate.split(' ');
|
|
2462
2473
|
}
|
|
2463
2474
|
if (Array.isArray(pathsToValidate)) {
|
|
2464
2475
|
paths = _handlePathsToValidate(paths, pathsToValidate);
|
|
2476
|
+
} else if (pathsToSkip) {
|
|
2477
|
+
paths = _handlePathsToSkip(paths, pathsToSkip);
|
|
2465
2478
|
}
|
|
2466
2479
|
if (paths.length === 0) {
|
|
2467
2480
|
return immediate(function() {
|
|
@@ -2478,17 +2491,11 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2478
2491
|
const validated = {};
|
|
2479
2492
|
let total = 0;
|
|
2480
2493
|
|
|
2481
|
-
const
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
return _this.$__schema.s.hooks.execPost('validate:error', _this, [_this], { error: error }, function(error) {
|
|
2485
|
-
callback(error);
|
|
2486
|
-
});
|
|
2487
|
-
}
|
|
2488
|
-
callback(null, _this);
|
|
2489
|
-
};
|
|
2494
|
+
for (const path of paths) {
|
|
2495
|
+
validatePath(path);
|
|
2496
|
+
}
|
|
2490
2497
|
|
|
2491
|
-
|
|
2498
|
+
function validatePath(path) {
|
|
2492
2499
|
if (path == null || validated[path]) {
|
|
2493
2500
|
return;
|
|
2494
2501
|
}
|
|
@@ -2544,12 +2551,18 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
|
|
|
2544
2551
|
--total || complete();
|
|
2545
2552
|
}, scope, doValidateOptions);
|
|
2546
2553
|
});
|
|
2547
|
-
}
|
|
2554
|
+
}
|
|
2548
2555
|
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2556
|
+
function complete() {
|
|
2557
|
+
const error = _complete();
|
|
2558
|
+
if (error) {
|
|
2559
|
+
return _this.$__schema.s.hooks.execPost('validate:error', _this, [_this], { error: error }, function(error) {
|
|
2560
|
+
callback(error);
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
callback(null, _this);
|
|
2552
2564
|
}
|
|
2565
|
+
|
|
2553
2566
|
};
|
|
2554
2567
|
|
|
2555
2568
|
/*!
|
|
@@ -2585,6 +2598,15 @@ function _handlePathsToValidate(paths, pathsToValidate) {
|
|
|
2585
2598
|
return ret;
|
|
2586
2599
|
}
|
|
2587
2600
|
|
|
2601
|
+
/*!
|
|
2602
|
+
* ignore
|
|
2603
|
+
*/
|
|
2604
|
+
function _handlePathsToSkip(paths, pathsToSkip) {
|
|
2605
|
+
pathsToSkip = new Set(pathsToSkip);
|
|
2606
|
+
paths = paths.filter(p => !pathsToSkip.has(p));
|
|
2607
|
+
return paths;
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2588
2610
|
/**
|
|
2589
2611
|
* Executes registered validation rules (skipping asynchronous validators) for this document.
|
|
2590
2612
|
*
|
|
@@ -2604,6 +2626,7 @@ function _handlePathsToValidate(paths, pathsToValidate) {
|
|
|
2604
2626
|
* @param {Array|string} pathsToValidate only validate the given paths
|
|
2605
2627
|
* @param {Object} [options] options for validation
|
|
2606
2628
|
* @param {Boolean} [options.validateModifiedOnly=false] If `true`, Mongoose will only validate modified paths, as opposed to modified paths and `required` paths.
|
|
2629
|
+
* @param {Array|string} [options.pathsToSkip] list of paths to skip. If set, Mongoose will validate every modified path that is not in this list.
|
|
2607
2630
|
* @return {ValidationError|undefined} ValidationError if there are errors during validation, or undefined if there is no error.
|
|
2608
2631
|
* @api public
|
|
2609
2632
|
*/
|
|
@@ -2627,8 +2650,13 @@ Document.prototype.validateSync = function(pathsToValidate, options) {
|
|
|
2627
2650
|
shouldValidateModifiedOnly = this.$__schema.options.validateModifiedOnly;
|
|
2628
2651
|
}
|
|
2629
2652
|
|
|
2653
|
+
let pathsToSkip = options && options.pathsToSkip;
|
|
2654
|
+
|
|
2630
2655
|
if (typeof pathsToValidate === 'string') {
|
|
2631
|
-
|
|
2656
|
+
const isOnePathOnly = pathsToValidate.indexOf(' ') === -1;
|
|
2657
|
+
pathsToValidate = isOnePathOnly ? [pathsToValidate] : pathsToValidate.split(' ');
|
|
2658
|
+
} else if (typeof pathsToSkip === 'string' && pathsToSkip.indexOf(' ') !== -1) {
|
|
2659
|
+
pathsToSkip = pathsToSkip.split(' ');
|
|
2632
2660
|
}
|
|
2633
2661
|
|
|
2634
2662
|
// only validate required fields when necessary
|
|
@@ -2638,11 +2666,10 @@ Document.prototype.validateSync = function(pathsToValidate, options) {
|
|
|
2638
2666
|
pathDetails[0];
|
|
2639
2667
|
const skipSchemaValidators = pathDetails[1];
|
|
2640
2668
|
|
|
2641
|
-
if (typeof pathsToValidate === 'string') {
|
|
2642
|
-
pathsToValidate = pathsToValidate.split(' ');
|
|
2643
|
-
}
|
|
2644
2669
|
if (Array.isArray(pathsToValidate)) {
|
|
2645
2670
|
paths = _handlePathsToValidate(paths, pathsToValidate);
|
|
2671
|
+
} else if (Array.isArray(pathsToSkip)) {
|
|
2672
|
+
paths = _handlePathsToSkip(paths, pathsToSkip);
|
|
2646
2673
|
}
|
|
2647
2674
|
const validating = {};
|
|
2648
2675
|
|
|
@@ -3552,6 +3579,19 @@ function applyVirtuals(self, json, options, toObjectOptions) {
|
|
|
3552
3579
|
let v;
|
|
3553
3580
|
const aliases = get(toObjectOptions, 'aliases', true);
|
|
3554
3581
|
|
|
3582
|
+
let virtualsToApply = null;
|
|
3583
|
+
if (Array.isArray(options.virtuals)) {
|
|
3584
|
+
virtualsToApply = new Set(options.virtuals);
|
|
3585
|
+
}
|
|
3586
|
+
else if (options.virtuals && options.virtuals.pathsToSkip) {
|
|
3587
|
+
virtualsToApply = new Set(paths);
|
|
3588
|
+
for (let i = 0; i < options.virtuals.pathsToSkip.length; i++) {
|
|
3589
|
+
if (virtualsToApply.has(options.virtuals.pathsToSkip[i])) {
|
|
3590
|
+
virtualsToApply.delete(options.virtuals.pathsToSkip[i]);
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3555
3595
|
if (!cur) {
|
|
3556
3596
|
return json;
|
|
3557
3597
|
}
|
|
@@ -3560,6 +3600,10 @@ function applyVirtuals(self, json, options, toObjectOptions) {
|
|
|
3560
3600
|
for (i = 0; i < numPaths; ++i) {
|
|
3561
3601
|
path = paths[i];
|
|
3562
3602
|
|
|
3603
|
+
if (virtualsToApply != null && !virtualsToApply.has(path)) {
|
|
3604
|
+
continue;
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3563
3607
|
// Allow skipping aliases with `toObject({ virtuals: true, aliases: false })`
|
|
3564
3608
|
if (!aliases && schema.aliases.hasOwnProperty(path)) {
|
|
3565
3609
|
continue;
|
|
@@ -3592,6 +3636,7 @@ function applyVirtuals(self, json, options, toObjectOptions) {
|
|
|
3592
3636
|
return json;
|
|
3593
3637
|
}
|
|
3594
3638
|
|
|
3639
|
+
|
|
3595
3640
|
/*!
|
|
3596
3641
|
* Applies virtuals properties to `json`.
|
|
3597
3642
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function sanitizeProjection(projection) {
|
|
4
|
+
if (projection == null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const keys = Object.keys(projection);
|
|
9
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
10
|
+
if (typeof projection[keys[i]] === 'string') {
|
|
11
|
+
projection[keys[i]] = 1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
package/lib/model.js
CHANGED
|
@@ -226,11 +226,8 @@ function _applyCustomWhere(doc, where) {
|
|
|
226
226
|
if (doc.$where == null) {
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const len = keys.length;
|
|
232
|
-
for (let i = 0; i < len; ++i) {
|
|
233
|
-
where[keys[i]] = doc.$where[keys[i]];
|
|
229
|
+
for (const key of Object.keys(doc.$where)) {
|
|
230
|
+
where[key] = doc.$where[key];
|
|
234
231
|
}
|
|
235
232
|
}
|
|
236
233
|
|
|
@@ -1411,6 +1408,71 @@ Model.syncIndexes = function syncIndexes(options, callback) {
|
|
|
1411
1408
|
}, this.events);
|
|
1412
1409
|
};
|
|
1413
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* Does a dry-run of Model.syncIndexes(), meaning that
|
|
1413
|
+
* the result of this function would be the result of
|
|
1414
|
+
* Model.syncIndexes().
|
|
1415
|
+
*
|
|
1416
|
+
* @param {Object} options not used at all.
|
|
1417
|
+
* @param {Function} callback optional callback
|
|
1418
|
+
* @returns {Promise} which containts an object, {toDrop, toCreate}, which
|
|
1419
|
+
* are indexes that would be dropped in mongodb and indexes that would be created in mongodb.
|
|
1420
|
+
*/
|
|
1421
|
+
|
|
1422
|
+
Model.diffIndexes = function diffIndexes(options, callback) {
|
|
1423
|
+
const toDrop = [];
|
|
1424
|
+
const toCreate = [];
|
|
1425
|
+
callback = this.$handleCallbackError(callback);
|
|
1426
|
+
return this.db.base._promiseOrCallback(callback, cb => {
|
|
1427
|
+
cb = this.$wrapCallback(cb);
|
|
1428
|
+
this.listIndexes((err, indexes) => {
|
|
1429
|
+
const schemaIndexes = this.schema.indexes();
|
|
1430
|
+
// Iterate through the indexes created in mongodb and
|
|
1431
|
+
// compare against the indexes in the schema.
|
|
1432
|
+
for (const index of indexes) {
|
|
1433
|
+
let found = false;
|
|
1434
|
+
// Never try to drop `_id` index, MongoDB server doesn't allow it
|
|
1435
|
+
if (isDefaultIdIndex(index)) {
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
for (const schemaIndex of schemaIndexes) {
|
|
1440
|
+
const key = schemaIndex[0];
|
|
1441
|
+
const options = _decorateDiscriminatorIndexOptions(this,
|
|
1442
|
+
utils.clone(schemaIndex[1]));
|
|
1443
|
+
if (isIndexEqual(key, options, index)) {
|
|
1444
|
+
found = true;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
if (!found) {
|
|
1449
|
+
toDrop.push(index.name);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
// Iterate through the indexes created on the schema and
|
|
1453
|
+
// compare against the indexes in mongodb.
|
|
1454
|
+
for (const schemaIndex of schemaIndexes) {
|
|
1455
|
+
const key = schemaIndex[0];
|
|
1456
|
+
let found = false;
|
|
1457
|
+
const options = _decorateDiscriminatorIndexOptions(this,
|
|
1458
|
+
utils.clone(schemaIndex[1]));
|
|
1459
|
+
for (const index of indexes) {
|
|
1460
|
+
if (isDefaultIdIndex(index)) {
|
|
1461
|
+
continue;
|
|
1462
|
+
}
|
|
1463
|
+
if (isIndexEqual(key, options, index)) {
|
|
1464
|
+
found = true;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
if (!found) {
|
|
1468
|
+
toCreate.push(key);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
cb(null, { toDrop, toCreate });
|
|
1472
|
+
});
|
|
1473
|
+
});
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1414
1476
|
/**
|
|
1415
1477
|
* Deletes all indexes that aren't defined in this model's schema. Used by
|
|
1416
1478
|
* `syncIndexes()`.
|
|
@@ -3568,6 +3630,139 @@ Model.bulkWrite = function(ops, options, callback) {
|
|
|
3568
3630
|
}, this.events);
|
|
3569
3631
|
};
|
|
3570
3632
|
|
|
3633
|
+
/**
|
|
3634
|
+
* takes an array of documents, gets the changes and inserts/updates documents in the database
|
|
3635
|
+
* according to whether or not the document is new, or whether it has changes or not.
|
|
3636
|
+
*
|
|
3637
|
+
* `bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)
|
|
3638
|
+
*
|
|
3639
|
+
* @param {[Document]} documents
|
|
3640
|
+
*
|
|
3641
|
+
*/
|
|
3642
|
+
Model.bulkSave = function(documents) {
|
|
3643
|
+
const preSavePromises = documents.map(buildPreSavePromise);
|
|
3644
|
+
|
|
3645
|
+
const writeOperations = this.buildBulkWriteOperations(documents, { skipValidation: true });
|
|
3646
|
+
|
|
3647
|
+
let bulkWriteResultPromise;
|
|
3648
|
+
return Promise.all(preSavePromises)
|
|
3649
|
+
.then(() => bulkWriteResultPromise = this.bulkWrite(writeOperations))
|
|
3650
|
+
.then(() => documents.map(buildSuccessfulWriteHandlerPromise))
|
|
3651
|
+
.then(() => bulkWriteResultPromise)
|
|
3652
|
+
.catch((err) => {
|
|
3653
|
+
if (!get(err, 'writeErrors.length')) {
|
|
3654
|
+
throw err;
|
|
3655
|
+
}
|
|
3656
|
+
return Promise.all(
|
|
3657
|
+
documents.map((document) => {
|
|
3658
|
+
const documentError = err.writeErrors.find(writeError => {
|
|
3659
|
+
const writeErrorDocumentId = writeError.err.op._id || writeError.err.op.q._id;
|
|
3660
|
+
return writeErrorDocumentId.toString() === document._id.toString();
|
|
3661
|
+
});
|
|
3662
|
+
|
|
3663
|
+
if (documentError == null) {
|
|
3664
|
+
return buildSuccessfulWriteHandlerPromise(document);
|
|
3665
|
+
}
|
|
3666
|
+
})
|
|
3667
|
+
).then(() => {
|
|
3668
|
+
throw err;
|
|
3669
|
+
});
|
|
3670
|
+
});
|
|
3671
|
+
};
|
|
3672
|
+
|
|
3673
|
+
function buildPreSavePromise(document) {
|
|
3674
|
+
return new Promise((resolve, reject) => {
|
|
3675
|
+
document.schema.s.hooks.execPre('save', document, (err) => {
|
|
3676
|
+
if (err) {
|
|
3677
|
+
reject(err);
|
|
3678
|
+
return;
|
|
3679
|
+
}
|
|
3680
|
+
resolve();
|
|
3681
|
+
});
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
function buildSuccessfulWriteHandlerPromise(document) {
|
|
3686
|
+
return new Promise((resolve, reject) => {
|
|
3687
|
+
handleSuccessfulWrite(document, resolve, reject);
|
|
3688
|
+
});
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
function handleSuccessfulWrite(document, resolve, reject) {
|
|
3692
|
+
if (document.isNew) {
|
|
3693
|
+
_setIsNew(document, false);
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
document.$__reset();
|
|
3697
|
+
document.schema.s.hooks.execPost('save', document, {}, (err) => {
|
|
3698
|
+
if (err) {
|
|
3699
|
+
reject(err);
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
resolve();
|
|
3703
|
+
});
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
/**
|
|
3707
|
+
*
|
|
3708
|
+
* @param {[Document]} documents The array of documents to build write operations of
|
|
3709
|
+
* @param {Object} options
|
|
3710
|
+
* @param {Boolean} options.skipValidation defaults to `false`, when set to true, building the write operations will bypass validating the documents.
|
|
3711
|
+
* @returns
|
|
3712
|
+
*/
|
|
3713
|
+
Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, options) {
|
|
3714
|
+
if (!Array.isArray(documents)) {
|
|
3715
|
+
throw new Error(`bulkSave expects an array of documents to be passed, received \`${documents}\` instead`);
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
setDefaultOptions();
|
|
3719
|
+
|
|
3720
|
+
const writeOperations = documents.reduce((accumulator, document, i) => {
|
|
3721
|
+
if (!options.skipValidation) {
|
|
3722
|
+
if (!(document instanceof Document)) {
|
|
3723
|
+
throw new Error(`documents.${i} was not a mongoose document, documents must be an array of mongoose documents (instanceof mongoose.Document).`);
|
|
3724
|
+
}
|
|
3725
|
+
const validationError = document.validateSync();
|
|
3726
|
+
if (validationError) {
|
|
3727
|
+
throw validationError;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
const delta = document.$__delta();
|
|
3732
|
+
const where = document.$__where(delta[0]);
|
|
3733
|
+
const changes = delta[1];
|
|
3734
|
+
|
|
3735
|
+
_applyCustomWhere(document, where);
|
|
3736
|
+
|
|
3737
|
+
document.$__version(where, delta);
|
|
3738
|
+
|
|
3739
|
+
if (document.isNew) {
|
|
3740
|
+
accumulator.push({
|
|
3741
|
+
insertOne: { document }
|
|
3742
|
+
});
|
|
3743
|
+
} else if (!utils.isEmptyObject(changes)) {
|
|
3744
|
+
accumulator.push({
|
|
3745
|
+
updateOne: {
|
|
3746
|
+
filter: where,
|
|
3747
|
+
update: changes
|
|
3748
|
+
}
|
|
3749
|
+
});
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
return accumulator;
|
|
3753
|
+
}, []);
|
|
3754
|
+
|
|
3755
|
+
return writeOperations;
|
|
3756
|
+
|
|
3757
|
+
|
|
3758
|
+
function setDefaultOptions() {
|
|
3759
|
+
options = options || {};
|
|
3760
|
+
if (options.skipValidation == null) {
|
|
3761
|
+
options.skipValidation = false;
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3571
3766
|
/**
|
|
3572
3767
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
3573
3768
|
* The document returned has no paths marked as modified initially.
|
|
@@ -4062,9 +4257,9 @@ Model.aggregate = function aggregate(pipeline, callback) {
|
|
|
4062
4257
|
*/
|
|
4063
4258
|
|
|
4064
4259
|
Model.validate = function validate(obj, pathsToValidate, context, callback) {
|
|
4065
|
-
if (
|
|
4066
|
-
// For convenience, if we're validating a document, make `context` default to
|
|
4067
|
-
// the model so users don't have to always pass `context`, re: gh-10132
|
|
4260
|
+
if ((arguments.length < 3) || (arguments.length === 3 && typeof arguments[2] === 'function')) {
|
|
4261
|
+
// For convenience, if we're validating a document or an object, make `context` default to
|
|
4262
|
+
// the model so users don't have to always pass `context`, re: gh-10132, gh-10346
|
|
4068
4263
|
context = obj;
|
|
4069
4264
|
}
|
|
4070
4265
|
|
package/lib/query.js
CHANGED
|
@@ -28,6 +28,7 @@ const isInclusive = require('./helpers/projection/isInclusive');
|
|
|
28
28
|
const mquery = require('mquery');
|
|
29
29
|
const parseProjection = require('./helpers/projection/parseProjection');
|
|
30
30
|
const removeUnusedArrayFilters = require('./helpers/update/removeUnusedArrayFilters');
|
|
31
|
+
const sanitizeProjection = require('./helpers/query/sanitizeProjection');
|
|
31
32
|
const selectPopulatedFields = require('./helpers/query/selectPopulatedFields');
|
|
32
33
|
const setDefaultsOnInsert = require('./helpers/setDefaultsOnInsert');
|
|
33
34
|
const slice = require('sliced');
|
|
@@ -957,13 +958,24 @@ Query.prototype.select = function select() {
|
|
|
957
958
|
|
|
958
959
|
const fields = this._fields || (this._fields = {});
|
|
959
960
|
const userProvidedFields = this._userProvidedFields || (this._userProvidedFields = {});
|
|
961
|
+
let sanitizeProjection = undefined;
|
|
962
|
+
if (this.model != null && utils.hasUserDefinedProperty(this.model.db.options, 'sanitizeProjection')) {
|
|
963
|
+
sanitizeProjection = this.model.db.options.sanitizeProjection;
|
|
964
|
+
} else if (this.model != null && utils.hasUserDefinedProperty(this.model.base.options, 'sanitizeProjection')) {
|
|
965
|
+
sanitizeProjection = this.model.base.options.sanitizeProjection;
|
|
966
|
+
} else {
|
|
967
|
+
sanitizeProjection = this._mongooseOptions.sanitizeProjection;
|
|
968
|
+
}
|
|
960
969
|
|
|
961
970
|
arg = parseProjection(arg);
|
|
962
971
|
|
|
963
972
|
if (utils.isObject(arg)) {
|
|
964
973
|
const keys = Object.keys(arg);
|
|
965
974
|
for (let i = 0; i < keys.length; ++i) {
|
|
966
|
-
|
|
975
|
+
let value = arg[keys[i]];
|
|
976
|
+
if (typeof value === 'string' && sanitizeProjection) {
|
|
977
|
+
value = 1;
|
|
978
|
+
}
|
|
967
979
|
fields[keys[i]] = value;
|
|
968
980
|
userProvidedFields[keys[i]] = value;
|
|
969
981
|
}
|
|
@@ -1368,6 +1380,7 @@ Query.prototype.getOptions = function() {
|
|
|
1368
1380
|
* - [lean](./api.html#query_Query-lean)
|
|
1369
1381
|
* - [populate](/docs/populate.html)
|
|
1370
1382
|
* - [projection](/docs/api/query.html#query_Query-projection)
|
|
1383
|
+
* - sanitizeProjection
|
|
1371
1384
|
*
|
|
1372
1385
|
* The following options are only for all operations **except** `update()`, `updateOne()`, `updateMany()`, `remove()`, `deleteOne()`, and `deleteMany()`:
|
|
1373
1386
|
*
|
|
@@ -1390,7 +1403,6 @@ Query.prototype.getOptions = function() {
|
|
|
1390
1403
|
*/
|
|
1391
1404
|
|
|
1392
1405
|
Query.prototype.setOptions = function(options, overwrite) {
|
|
1393
|
-
|
|
1394
1406
|
// overwrite is only for internal use
|
|
1395
1407
|
if (overwrite) {
|
|
1396
1408
|
// ensure that _mongooseOptions & options are two different objects
|
|
@@ -1434,6 +1446,14 @@ Query.prototype.setOptions = function(options, overwrite) {
|
|
|
1434
1446
|
this._mongooseOptions.overwriteDiscriminatorKey = options.overwriteDiscriminatorKey;
|
|
1435
1447
|
delete options.overwriteDiscriminatorKey;
|
|
1436
1448
|
}
|
|
1449
|
+
if ('sanitizeProjection' in options) {
|
|
1450
|
+
if (options.sanitizeProjection && !this._mongooseOptions.sanitizeProjection) {
|
|
1451
|
+
sanitizeProjection(this._fields);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
this._mongooseOptions.sanitizeProjection = options.sanitizeProjection;
|
|
1455
|
+
delete options.sanitizeProjection;
|
|
1456
|
+
}
|
|
1437
1457
|
|
|
1438
1458
|
if ('defaults' in options) {
|
|
1439
1459
|
this._mongooseOptions.defaults = options.defaults;
|
package/lib/validoptions.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.13.0",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -249,4 +249,4 @@
|
|
|
249
249
|
"type": "opencollective",
|
|
250
250
|
"url": "https://opencollective.com/mongoose"
|
|
251
251
|
}
|
|
252
|
-
}
|
|
252
|
+
}
|