I'm implementing a small webserver in Node.js and Express and I was wondering how can I access to data variable inside the database callback? This whole code is inside an express route function and the db is sqlite3
var data = {
color: "blue",
}
db.all("SELECT * FROM connections WHERE ip='" + req.connection.remoteAddress + "' AND connection='connected'",function(err,rows){
console.log(rows.length)
if (rows.length > 0) {
data["color"] = "green";
}else {
data["color"] = "red";
}
});