Friday, 12 May 2017

Node & Tedious - Result as a Map

I'm using Node with Tedious and am executing the following query:

var request = new Request("SELECT * FROM table", function (err, rowCount, rows) {
    res.render('index', {countries: database.map(rows)});
}

The database.map is my own:

var map = function(rows) {
    var mapped = [];
    rows.forEach(function (row) {
        var mappedRow = {};
        row.forEach(function (column) {
            mappedRow[column.metadata.colName] = column.value;
        });
        mapped.push(mappedRow);
    });
    return mapped;
};

Do I really have to jump through those hoops? Or am I using the wrong method etc? I'm new to all of this.



via Kong

No comments:

Post a Comment