I've got a Node.js server with Express and Jade running. On an HTTP request the server will execute the following function:
function home(req, res) {
res.render("site/index", {recordset: recordset}); //render the Jade template
}
Now I would like to pass in an array to the above recordset variable that I can loop through in Jade to populate a drop-down on my html page. I've retrieved the desired array like so:
function runSQLSelect() {
sql.connect(config.db, function(err) {
var request = new sql.Request();
request.query("select MyColumn FROM MyTable", function(err, recordset) {
console.log(recordset);
});
});
}
What is a proper way to asynchronously run the SQL query and pass the subsequent result into my Jade template?