Permalink
Browse files

Don't freak out if we're initializing an object that has already been…

… wrapped
  • Loading branch information...
JoshuaGross committed Feb 9, 2013
1 parent 04220ee commit b7809b4194719620898bf7ead300afc749a1a62d
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/mongoose-subpopulate.js
@@ -93,7 +93,7 @@ var wrapSchema = exports.wrapSchema = function wrapSchema (schema) {
var initOrig = schema.init;
schema.init = function initWrapped (obj, callback) {
var wrapCallback = (callback ? db_callback('init failed', callback) : null);
- return wrapModelObject(initOrig.call(schema, obj, wrapCallback));
+ return wrapModelObject(initOrig.call(schema, (obj && obj.mongooseLink ? obj.mongooseLink : obj), wrapCallback));
};
schema.init.mSubpopulateWrapped = true;
}

0 comments on commit b7809b4

Please sign in to comment.