I have developed a pure node.js REST application server that connects to a MSSQL DB and uses endpoints to request employee records.
I am receiving duplicate records back when I request all employee records or when I request one employee record using a REST GET request. The response has both a recordsets and recordset section. Is this correct and if it is, how do I prevent duplicate records?
You help would be greatly appreciated.
exports.executeSql = function (sql, callback) {
var conn = new sqlDb.ConnectionPool(settings.dbConfig);
conn.connect()
.then(function () {
var req = new sqlDb.Request(conn);
req.query(sql)
.then(function (recordset) {
callback(recordset);
})
.catch(function (err) {
console.log(err);
callback(null, err);
});
})
.catch(function (err) {
console.log(err);
callback(null, err);
});
};
This is the JSON response I get back when requesting employee record where employee_number = 100
{
"recordsets": [
[
{
"RECORD_KEY": "951112558721130050",
"EMPLOYEE_NUMBER": "100",
"FIRST_NAME": "SAMPLE CLERK",
"LAST_NAME": null,
}
]
],
"recordset": [
{
"RECORD_KEY": "951112558721130050",
"EMPLOYEE_NUMBER": "100",
"FIRST_NAME": "SAMPLE CLERK",
"LAST_NAME": null,
}
],
"output": {},
"rowsAffected": [
1
]
}
via joey.coyle
No comments:
Post a Comment