i am running a simple select query. the code runs fine and its returning the resultset as well showing all the column values which are in character format but showing "nodeJava_java_math_BigDecimal{}" insted of decimal format columns ?
var Teradata = require('node-teradata');
var config = {
url: 'jdbc:teradata://abc.com/database=abab',
username: '****',
password: '****',
driver: './jars/',
minPoolSize: 1,
maxPoolSize: 100,
keepalive: {
interval: 60000,
query: 'SELECT 1',
enabled: true
}
};
var teradata = new Teradata(config);
var sql = "select name,QTY from products where id='700018'";
return teradata.read(sql)
.then(function(response) {
console.log(response);
});
the result its printing on console is:
[{name:'Apple Juice',QTY:nodeJava_java_math_BigDecimal{}}]
You can retype the properties of the returned object with the JavaScript types you know you'll be working with, using methods like Number([...]) or .toString()
return teradata.read(sql)
.then(function(response) {
return response.map(respObj => objExtractor(respObj));
});
function objExtractor(teradataObj) {
return {
name: teradataObj.name.toString(),
QTY: Number(teradataObj.QTY).toFixed(0)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With