Permalink
Browse files

Call wrapModelObject around init()'d models

  • Loading branch information...
JoshuaGross committed Jan 6, 2013
1 parent 7ab8be6 commit 75e04e0ee556d4019dde5539883b498ad86fa9a6
Showing with 9 additions and 1 deletion.
  1. +8 −0 lib/mongoose-subpopulate.js
  2. +1 −1 package.json
@@ -89,6 +89,14 @@ var wrapSchema = exports.wrapSchema = function wrapSchema (schema) {
};
schema.findById.mSubpopulateWrapped = true;
}
+ if (schema.init && !schema.init.mSubpopulateWrapped) {
+ 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));
+ };
+ schema.init.mSubpopulateWrapped = true;
+ }
if (schema.count && !schema.count.mSubpopulateWrapped) {
var countOrig = schema.count;
schema.count = function countWrapped (conditions, callback) {
View
@@ -1,6 +1,6 @@
{
"name": "mongoose-subpopulate",
- "version": "0.1.15",
+ "version": "0.1.16",
"main": "./lib/mongoose-subpopulate.js",
"scripts": {},
"repository": {

0 comments on commit 75e04e0

Please sign in to comment.