I have a module that search documents inside mongodb
.
When I call the check_permitions
(with the argument), I get "undefined" return from the function, but the console.log(rslts[0].faq)
return the right object. What is the problem?
var iapp = require('./app');
exports.check_permitions = function(user_id) {
iapp.website_coll.find({}).where('admins_id').equals(user_id).exec(function(err, rslts) {
if (err) {
console.log(err);
} else if (rslts) {
console.log(rslts[0].faq);
return (rslts[0].faq);
} else if (!rslts) {
console.log('no r');
return (rslts[0].faq);
}
});
console.log('top');
};