im trying to save the result of the MySql query in a variable using node-mysql model and node.js, so I have this code:
connection.query("select * from ROOMS", function(err, rows){ if(err) { throw err; } else { console.log(rows); } });
and the result:
[ { idRooms: 1, Room_Name: 'dd' }, { idRooms: 2, Room_Name: 'sad' } ]
so I need to save this result in a variable, so I try like this:
var someVar = connection.query("select * from ROOMS", function(err, rows){ if(err) { throw err; } else { return rows; } }); console.log(someVar);
but not working, thanks for any help in advance.
source share