I am trying to fetch user data during a login process. Data stored in rethinkDb. The flow is:
• Request is routed to a controller (via express)
• Controller choose correct handler
• Handler call the dao.get():
  login: function (email, password, res) {
        var feedback = daouser.get(email);
        if (feedback.success) {
            var user = feedback.data;
            //Do some validatios...
        }       
        res.status = 200;
        res.send(feedback);
    },
• dao.get() code is:
get: function (email) {        
    var feedback = new Feedback();
    self.app.dbUsers.filter({email: email}).run().then(function (result) {
        var user = result[0];
        feedback.success = true;
        feedback.data = user;
        return feedback;
    });
}
But since the call is via a promise, the dao.get return before the actual “Then” function is call and the controller gets undefined feedback…
Something wrong with my design…
 
    