//This is my models
module.exports.show_deatils=function(req,res,callback){
var resultArray=[];
mongo.connect(url,function(err,db){
assert.equal(null,err);
var cursor=db.collection('users').find();
cursor.forEach(function(doc,err){
assert.equal(null,err);
resultArray.push(doc);
console.log("came inside the function")
return resultArray;
});
});
}
//This is my routes
router.get('/restful', function(req, res){
console.log("before");
User.show_deatils(function(req,res){
console.log(resultArray);
req.session.resultArray=resultArray;
});
res.render('restful',{items:req.session.resultArray});
});
//Here I am calling a function from routes to models (show_details).The issue which I am facing is I am calling the function.The method is being called.The array "resultArray" is been populated with the values.But I am not been able to return the particular value.How can we do it?