BIGINT field is string in getterMethods
See original GitHub issueI have the next model:
var Sequelize = require('sequelize');
module.exports = function () {
return {
attributes: {
uuid : Sequelize.STRING,
ccc : {type: Sequelize.BIGINT, allowNull: false},
vvv : Sequelize.BIGINT,
bbb : Sequelize.BIGINT
},
options: {
getterMethods: {
outstandingBalance: function() {
var ccc = this.ccc ? this.ccc : 0,
vvv = this.vvv ? this.vvv : 0,
bbb = this.bbb ? this.bbb : 0;
// the same if I do this.getDataValue('vvv') , I receive string as well
console.log(ccc, vvv, bbb);
return (ccc + vvv - bbb);
}
},
classMethods: {},
instanceMethods: {
},
tableName: 'xxx_calc'
}
};
};
Which produces the next to the console:
The values are strings for some reason, however, if I would completely receive the model and print the value from the resolve method, the value of the ccc
, vvv
and bbb
would be number.
I mean here:
YYY.find({ /* where */
}).then(function (yyy) {
console.log(yyy.uuu.vvv);
return reply(yyy);
});
Could you tell me how can I receive the number
values in the getterMethods
as well? Is that normal behaviour?
Regards,
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
getter - JavaScript - MDN Web Docs - Mozilla
The get syntax binds an object property to a function that will be called when that property is looked up. It can also...
Read more >ResultSet (Java Platform SE 7 ) - Oracle Help Center
The ResultSet interface provides getter methods ( getBoolean , getLong , and so on) for retrieving column values from the current row.
Read more >SqlType (Apache Calcite Avatica API)
Extends the information in Types . The information in the following conversions tables (from the JDBC 4.1 specification) is held in members of...
Read more >Using basic JDBC data types - SQL Server - Microsoft Learn
bigint, BIGINT, long. binary, BINARY, byte[]. bit, BIT, boolean. char, CHAR, String. date, DATE, java.sql.Date.
Read more >Mapping SQL and Java Types
Conversely, when a String object is sent to a CHAR(n) field, the driver and/or the ... The recommended Java mapping for the BIGINT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems it’s strings all around in the example you posted? Which is as it should be, since bigint can’t reliably be stored in javascript ints, right? Accessing properties directly or with get also returns strings
Look into bignumber support in node myslq in you want numbers: https://github.com/felixge/node-mysql/#connection-options, in connection with
dialectOptions
http://docs.sequelizejs.com/en/latest/api/sequelize/#new-sequelizedatabase-usernamenull-passwordnull-options