Retrieve affected row

47 visualizações
Pular para a primeira mensagem não lida

Beto Sosa

não lida,
4 de out. de 2016, 18:21:1904/10/2016
para node-mysql

Hi I am starting to use this package, and I was wodering if there is a way to get all the affected rows of  a query.
For example, when you insert a new row, the driver give us a callback object with the key insertId I dont know if I there is a way to get all the object not just the id

connection.query('INSERT INTO posts SET ?', {title: 'test'}, function(err, result) {
 
if (err) throw err;

 
console.log(result.insertId);
});


Something like this

connection.query('UPDATE posts SET title = ? WHERE...', { titles: 'New title' }, function(err, result) {
    console
.log(result.updatedRow)
}
)





Thank you

Kiss Koppány

não lida,
19 de out. de 2016, 19:22:5319/10/2016
para node-mysql
You could simply just write another query inside that one and get the row you need based on the inserId.
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem