Answer the question
In order to leave comments, you need to log in
How to extract new entry and NodeJS + mysql bases?
Tell me how to correctly implement the output of a new row from the database on the initiative of the server?
The server is connected to the client via sockets.
Tried to do so.
latest - The ID of the last message printed.
message[0] - My ID
message[1] - Interlocutor ID
setInterval(function(){
connection.query('SELECT * FROM messages WHERE id>'+latest+' && ((sender='+message[0]+' && recipient='+message[1]+') || (sender='+message[1]+' && recipient='+message[0]+')) ORDER BY id DESC', function(err, rows, fields) {
if (err) throw err;
// Отправка данных пользователю
});
},1);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question