Sergy Sergy - 1 month ago 8
MySQL Question

How to get rows with a bit typed fields from mysql in node.js?

I am using a mysql npm package for connection and trying to get data from table, which has columns with type BIT.
But these columns have gone as:

"isBasic": {
"type": "Buffer",
"data": [
1
]
},


How can I map them to boolean type?

Answer

The bit data type is not perfectly used in mysql package. We usually use tinyint in tables to store 0 and 1 and then just do the comparison in Javscript to determine true or false.

Comments