How can i return after a Mongoose find a variable to the function above? This is my code:
function getData(user, token) {
Collection.findOne({username:user, accessToken:token}, function(err, profile){
if(!profile) {
return false;
}
return true;
});
}
Because it is a function can't i return a value back to getData(). So i have tried to do this with global variables, that worked but i didn't like the way that i had to make a global variable for all the Mongoose find's. Is there an other or better way to return a value back to the function getData?