Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Call wrapModelObject around init()'d models

  • Loading branch information...
commit 75e04e0ee556d4019dde5539883b498ad86fa9a6 1 parent 7ab8be6
@JoshuaGross authored
Showing with 9 additions and 1 deletion.
  1. +8 −0 lib/mongoose-subpopulate.js
  2. +1 −1  package.json
View
8 lib/mongoose-subpopulate.js
@@ -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
2  package.json
@@ -1,6 +1,6 @@
{
"name": "mongoose-subpopulate",
- "version": "0.1.15",
+ "version": "0.1.16",
"main": "./lib/mongoose-subpopulate.js",
"scripts": {},
"repository": {
Please sign in to comment.
Something went wrong with that request. Please try again.