I am developing application in Node.js with ExpressJS. I am new to event-driven development and I have a basic question about event-driven architecture and visibility.
I have a service which needs to make several MySQL queries and return them as one JSON object. Something like this:
exports.someService = function(..) {
mysql.query("some select", function(rows...) {
// here I want to store the rows in a way to be visible from parent function
});
mysql.query("some other select where id=some value from previous select", function(rows...) {
res.send(rows from this query + rows from previous query)
});
}
How can I do this?