From f83c9cc154ff8ca4dddace8f2ac4f1c691dfe943 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Sun, 14 May 2017 15:09:32 +0930 Subject: [PATCH 01/10] fix typo --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index a2eb2b92dc6..31302f24782 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,7 +5,7 @@ **What is the current behavior?** **If the current behavior is a bug, please provide the steps to reproduce.** - + **What is the expected behavior?** From bdc1b9c73f706f2b234a13a9e3c3ce4d0bc4eb22 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 16 May 2017 12:56:53 -0600 Subject: [PATCH 02/10] docs(populate): add details re: justOne in virtual populate Re: #4263 --- docs/populate.jade | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/populate.jade b/docs/populate.jade index bd78b74c23f..3c6844189ab 100644 --- a/docs/populate.jade +++ b/docs/populate.jade @@ -330,7 +330,10 @@ block content BandSchema.virtual('members', { ref: 'Person', // The model to use localField: 'name', // Find people where `localField` - foreignField: 'band' // is equal to `foreignField` + foreignField: 'band', // is equal to `foreignField` + // If `justOne` is false, 'members' will be a single doc as opposed to + // an array. `justOne` is false by default. + justOne: false }); var Person = mongoose.model('Person', personSchema); From 76e5c2e87095b5e8cdfc2247656fb91b4698da53 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 16 May 2017 16:54:44 -0600 Subject: [PATCH 03/10] docs: remove dead plugins repo and add content links Re: #5247 --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index e5fe25e9321..8280d049fcb 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,7 @@ Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed ## Plugins -Check out the [plugins search site](http://plugins.mongoosejs.io/) to see hundreds of related modules from the community. - -Build your own Mongoose plugin through [generator-mongoose-plugin](https://github.com/huei90/generator-mongoose-plugin). +Check out the [plugins search site](http://plugins.mongoosejs.io/) to see hundreds of related modules from the community. Next, learn how to write your own plugin from the [docs](http://mongoosejs.com/docs/plugins.html) or [this blog post](http://thecodebarbarian.com/2015/03/06/guide-to-mongoose-plugins). ## Contributors From 236c87ea5dc29db7158b9ae4278079dae9ad31e9 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 16 May 2017 17:42:43 -0600 Subject: [PATCH 04/10] fix(model): skip index build if connecting after model init and autoIndex false Fix #5176 --- lib/model.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/model.js b/lib/model.js index 7af6cc744a9..fc27b03aeb7 100644 --- a/lib/model.js +++ b/lib/model.js @@ -874,7 +874,7 @@ for (var i in EventEmitter.prototype) { Model.init = function init() { if ((this.schema.options.autoIndex) || - (this.schema.options.autoIndex === null && this.db.config.autoIndex)) { + (this.schema.options.autoIndex == null && this.db.config.autoIndex)) { this.ensureIndexes({ __noPromise: true, _automatic: true }); } @@ -967,6 +967,11 @@ function _ensureIndexes(model, options, callback) { }; var create = function() { + if (model.schema.options.autoIndex === false || + (model.schema.options.autoIndex == null && model.db.config.autoIndex === false)) { + return done(); + } + var index = indexes.shift(); if (!index) return done(); From 7393f10a3044400ef1a072ec7d9fff9d2ea4c1e9 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 17 May 2017 11:57:24 -0600 Subject: [PATCH 05/10] test(document): repro #5250 --- test/document.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/document.test.js b/test/document.test.js index d237d960c1f..a5186c34e46 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -4037,6 +4037,23 @@ describe('document', function() { done(); }); + it('deeply nested virtual paths (gh-5250)', function(done) { + var TestSchema = new Schema({}); + TestSchema. + virtual('a.b.c'). + get(function() { + return this.v; + }). + set(function(value) { + this.v = value; + }); + + var TestModel = db.model('gh5250', TestSchema); + var t = new TestModel({'a.b.c': 5}); + assert.equal(t.a.b.c, 5); + done(); + }); + it('JSON.stringify nested errors (gh-5208)', function(done) { var AdditionalContactSchema = new Schema({ contactName: { From 4f78b3b449c3dbd3811cdb6da5c03596d8653cbd Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 17 May 2017 11:57:31 -0600 Subject: [PATCH 06/10] fix(document): check for virtual before setting nested non-existent path Fix #5250 --- lib/document.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/document.js b/lib/document.js index 4fb46147d1b..0d19f861987 100644 --- a/lib/document.js +++ b/lib/document.js @@ -663,18 +663,6 @@ Document.prototype.set = function(path, val, type, options) { var schema; var parts = path.split('.'); - // gh-4578, if setting a deeply nested path that doesn't exist yet, create it - var cur = this._doc; - var curPath = ''; - for (i = 0; i < parts.length - 1; ++i) { - cur = cur[parts[i]]; - curPath += (curPath.length > 0 ? '.' : '') + parts[i]; - if (!cur) { - this.set(curPath, {}); - cur = this.getValue(curPath); - } - } - if (pathType === 'adhocOrUndefined' && strict) { // check for roots that are Mixed types var mixed; @@ -709,6 +697,18 @@ Document.prototype.set = function(path, val, type, options) { schema = this.$__path(path); } + // gh-4578, if setting a deeply nested path that doesn't exist yet, create it + var cur = this._doc; + var curPath = ''; + for (i = 0; i < parts.length - 1; ++i) { + cur = cur[parts[i]]; + curPath += (curPath.length > 0 ? '.' : '') + parts[i]; + if (!cur) { + this.set(curPath, {}); + cur = this.getValue(curPath); + } + } + var pathToMark; // When using the $set operator the path to the field must already exist. From ec7678627d0423c9a1a253b23e644de6477de04f Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 17 May 2017 22:52:16 -0600 Subject: [PATCH 07/10] fix(connection): ensure callback arg to openSet() is handled properly Fix #5249 --- lib/connection.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/connection.js b/lib/connection.js index 0c7e138238f..cf348f89cce 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -487,6 +487,8 @@ Connection.prototype._handleOpenSetArgs = function(uris, database, options, call if (options && options.config) { this.config.autoIndex = options.config.autoIndex !== false; } + + return callback; }; /*! From bb1f92a8c2638d19883991eacb834468aeb0887d Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 17 May 2017 22:59:11 -0600 Subject: [PATCH 08/10] chore: release 4.9.10 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 928cc7fc8b1..732ebd21cc1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +4.9.10 / 2017-05-17 +=================== + * fix(connection): ensure callback arg to openSet() is handled properly #5249 + * docs: remove dead plugins repo and add content links #5247 + * fix(model): skip index build if connecting after model init and autoIndex false #5176 + 4.9.9 / 2017-05-13 ================== * docs: correct value for Query#regex() #5230 diff --git a/package.json b/package.json index 3a2b5f8fc99..ce79d3a06a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongoose", "description": "Mongoose MongoDB ODM", - "version": "4.9.10-pre", + "version": "4.9.10", "author": "Guillermo Rauch ", "keywords": [ "mongodb", From 07b12f0e165420e3a31201d89f6f01393f0eb166 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 17 May 2017 23:02:20 -0600 Subject: [PATCH 09/10] chore: now working on 4.9.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce79d3a06a0..a1378f19b5f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongoose", "description": "Mongoose MongoDB ODM", - "version": "4.9.10", + "version": "4.9.11-pre", "author": "Guillermo Rauch ", "keywords": [ "mongodb", From 373bb6fe40cdd7d64ea58ffaa009aeb1efab1ac3 Mon Sep 17 00:00:00 2001 From: clozanosanchez Date: Thu, 18 May 2017 16:24:45 +0200 Subject: [PATCH 10/10] Update clone method to include indexes --- lib/schema.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/schema.js b/lib/schema.js index 22ff54efb2c..8dce1252591 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -274,6 +274,7 @@ Schema.prototype.clone = function() { s.methods = utils.clone(this.methods); s.statics = utils.clone(this.statics); s._plugins = utils.clone(this._plugins); + s._indexes = utils.clone(this._indexes); s.s.hooks = this.s.hooks.clone(); return s; };