我使用节点js从sqlserver获得记录,现在我想使用节点js以表格式显示记录,请为此提供帮助。下面是我从sql server获取记录的代码
var express = require('express');
var app = express();
var http = require('http');
app.get('/', function (req, res) {
var sql = require("mssql");
var config = {
user: 'sa',
password: '*******',
server: 'localhost',
database: 'testDB'
};
sql.connect(config, function (err) {
if (err) console.log(err);
var request = new sql.Request();
request.query('select * from SkillSet', function (err, recordset) {
if (err) console.log(err)
// send records as a response
res.json(recordset);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is running..');
});
及以下输出
{"recordsets":[[{"Technology":"Visual studio code","Owner":"V.Amutha Christy Umarklet","Team":"Trainees "},{"Technology":"Visual studio code","Owner":"V.Amutha Christy Umarklet","Team":".NET Team"},{"Technology":"JSON","Owner":"V.Amutha Christy Umarklet","Team":"Trainees "}],"output":{},"rowsAffected":[27]}