Here is my action which will get all users from users collection
app.post('/login', function(req,res,next){
users = self._db.get('users', {})
})
And this is my function in database class
this.get = function( col, opt )
{
var result = [],
opt = opt || {};
query = db.collection(col).find( opt );
query.each( function(err, doc)
{
console.log( doc );
if( doc != null )
{
result.push( doc );
}
});
return result;
};
and when I log users object it returns empty array but when I log each document inside function it works successfully
question is how can I get result asyncronously?