dimanche 1 mars 2015

Mongoose.findOne doesn't return anything, why?

I need to return the search results from Mongoose.findOne to variable



results = Lang.findOne({page: params.page,lang: params.lang, param: params.param}, function(err, lang) {
if( err || !lang) {
console.log("No translation!");
} else {
return lang.trans;
};
}


Is there a way to do this? I tried several hours to find a solution with async. functions and nothing ... I also found articles where it was said that this is impossible, but is there any alternative for realize this?


It's really important to me because I need this to my multilingual project, I need to get the translation:



res.render('index',{titleGen : req.__({page:'home', lang:req.locale, param:'hello'})});

Aucun commentaire:

Enregistrer un commentaire