advaya-mongo
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -14,3 +14,3 @@ var ObjectId= require('mongodb').ObjectId; | ||
var allModels= input.allModels; | ||
input.model.populate= function (obj,fields) { | ||
input.model.populate= function (obj,fields,options) { | ||
if(model.schema.hasOwnProperty('reference') && typeof(model.schema.reference)==="object") | ||
@@ -69,2 +69,20 @@ { | ||
.then(function (allResults) { | ||
if(options && options.hasOwnProperty('toJSON')) | ||
{ | ||
allIds.map(function (allId,index) { | ||
var toJSON= allModels[allId.reference].schema.toJSON; | ||
if(toJSON && typeof(toJSON)==="function") | ||
{ | ||
allResults[index]=allResults[index].map(function (allResult) { | ||
allResult=toJSON(allResult); | ||
return allResult; | ||
}); | ||
} | ||
}); | ||
return allResults; | ||
} | ||
else | ||
return allResults; | ||
}) | ||
.then(function (allResults) { | ||
return allResults.map(function(result){ | ||
@@ -71,0 +89,0 @@ return _.groupBy(result,'_id'); |
{ | ||
"name": "advaya-mongo", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Advaya mongo plugin", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27964
912