Skip to content

Commit

Permalink
Allow methods from plugins, etc. to be accessed from wrapped objects
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaGross committed Oct 26, 2012
1 parent b3c5650 commit de1a3d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/mongoose-subpopulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ function wrapModelObject (object) {
})(i);
}
}

// Getters and setters for all schema attributes
var schema = (object._schema || object.schema).paths;
for (var i in schema) {
(function (attr) {
Expand Down Expand Up @@ -370,6 +372,13 @@ function wrapModelObject (object) {
})(i);
}

// Allow all methods (from plugins, etc) to be accessed
for (var i in wrappedObject.schema.methods) {
(function (methodName) {
wrappedObject[methodName] = wrappedObject.schema.methods[methodName];
})(i);
}

wrappedObject.getBare = function (callback) {
var keys = Object.keys(wrappedObject.schema.paths);

Expand Down

0 comments on commit de1a3d3

Please sign in to comment.