i found some plugin of mongodb for nodejs ,but it seems alway use callback function to return search result, i just wanna to get the result in return by straight
I can't get the correct return by use this code:
index.prototype.a = function(){
var vars = {};
vars.something1 = {};
vars.something2 = 123;
mongous("db.test").find({name:'shura'},function(r){
if(r){
vars.something3= true;
}else{
vars.something3= false;
}
});
return vars;
}
This code is what I want:
index.prototype.a = function(){
var vars = {};
vars.something1 = {};
vars.something2 = 123;
var result = mongo_plugin("db.test").search({name:'shura'});
vars.something3 = result?true:false;
return vars;
}
how can i make the vars.something3 exist in return?