diff --git a/lib/cursor/QueryCursor.js b/lib/cursor/QueryCursor.js index 32a130f7d7d..de38b820fea 100644 --- a/lib/cursor/QueryCursor.js +++ b/lib/cursor/QueryCursor.js @@ -441,7 +441,7 @@ function _populateBatch() { function _nextDoc(ctx, doc, pop, callback) { if (ctx.query._mongooseOptions.lean) { - return ctx.model.hooks.execPost('find', ctx.query, [doc], err => { + return ctx.model.hooks.execPost('find', ctx.query, [[doc]], err => { if (err != null) { return callback(err); } @@ -453,7 +453,7 @@ function _nextDoc(ctx, doc, pop, callback) { if (err != null) { return callback(err); } - ctx.model.hooks.execPost('find', ctx.query, [doc], err => { + ctx.model.hooks.execPost('find', ctx.query, [[doc]], err => { if (err != null) { return callback(err); } diff --git a/lib/document.js b/lib/document.js index e37b241a124..127014cec1c 100644 --- a/lib/document.js +++ b/lib/document.js @@ -600,7 +600,6 @@ Document.prototype.$__init = function(doc, opts) { this.constructor.emit('init', this); this.$__._id = this._id; - return this; }; diff --git a/test/query.cursor.test.js b/test/query.cursor.test.js index 5fde51466cd..46751ab9cc1 100644 --- a/test/query.cursor.test.js +++ b/test/query.cursor.test.js @@ -692,8 +692,8 @@ describe('QueryCursor', function() { it('post hooks (gh-9435)', function() { const schema = new mongoose.Schema({ name: String }); - schema.post('find', function(doc) { - doc.name = doc.name.toUpperCase(); + schema.post('find', function(docs) { + docs.forEach(doc => { doc.name = doc.name.toUpperCase(); }); }); const Movie = db.model('Movie', schema);