Permalink
Browse files

Allow methods from plugins, etc. to be accessed from wrapped objects

  • Loading branch information...
1 parent b3c5650 commit de1a3d36384d5fb37eef4cc56507ad1ac6efab9c @JoshuaGross committed Oct 26, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/mongoose-subpopulate.js
@@ -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) {
@@ -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);

0 comments on commit de1a3d3

Please sign in to comment.