mongoose-autopopulate
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -0,1 +1,6 @@ | ||
0.5.0 / 2016-11-29 | ||
================== | ||
* feat: support lean #27 #14 [siboulet](https://github.com/siboulet) | ||
* feat: support virtual autopopulate #24 [siboulet](https://github.com/siboulet) | ||
0.4.0 / 2015-09-03 | ||
@@ -2,0 +7,0 @@ ================== |
13
index.js
@@ -5,2 +5,3 @@ var mongoose = require('mongoose'); | ||
var pathsToPopulate = []; | ||
eachPathRecursive(schema, function(pathname, schemaType) { | ||
@@ -26,3 +27,15 @@ var option; | ||
if (schema.virtuals) { | ||
Object.keys(schema.virtuals).forEach(function(pathname) { | ||
if (schema.virtuals[pathname].options.autopopulate) { | ||
pathsToPopulate.push({ | ||
options: defaultOptions(pathname, schema.virtuals[pathname].options), | ||
autopopulate: schema.virtuals[pathname].options.autopopulate, | ||
}); | ||
} | ||
}); | ||
} | ||
var autopopulateHandler = function() { | ||
if (this._mongooseOptions && this._mongooseOptions.lean) return; | ||
var numPaths = pathsToPopulate.length; | ||
@@ -29,0 +42,0 @@ for (var i = 0; i < numPaths; ++i) { |
{ | ||
"name": "mongoose-autopopulate", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Always populate() certain fields in your mongoose schemas", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha ./test/unit.js", | ||
"test-all": "mocha ./test/*.js", | ||
"test": "mocha ./test/*.js", | ||
"test-integration": "mocha ./test/integration.js", | ||
@@ -23,7 +22,7 @@ "test-travis": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*" | ||
"devDependencies": { | ||
"acquit": "0.0.3", | ||
"istanbul": "0.3.2", | ||
"mocha": "2.2.5", | ||
"mongoose": "4.0.6", | ||
"underscore": "1.5.2" | ||
"acquit": "0.4.1", | ||
"istanbul": "0.4.5", | ||
"mocha": "3.2.0", | ||
"mongoose": "4.x", | ||
"underscore": "1.8.3" | ||
}, | ||
@@ -30,0 +29,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
35796
13
461