I have array 'results' of messages from database, and now I want to add nickname to this message also from database. Array that I'am receiving from database is sorted by date, but when i use this code, results are in kind of random order.
Promise.each(results, function(message) {
users.db.find({id64: message.id64}).then(function(user) {
message.nick = user[0].nick;
socket.emit('chat message toClient', message);
})
})
I may approach this from the wrong side.
I think you need a return keyword before users.db...