node-mysql2: TypeCast seems doesnt work
const mysql2 = require('mysql2');
const pool = mysql2.createPool({
host:'localhost', user: 'admindb', database: 'tests',password:'password',charset:'UTF8MB4_UNICODE_CI',timezone:'Z',
typeCast: (field, next) => {
console.log('typeCast');
if (field.type === "BIT") {
console.log(field);
console.log(field.buffer());
return field.buffer()[0] == 1;
}
return next()
}
});;
const promisePool = pool.promise();
export default {pool, promisePool}
Doesn’t call with execute. dup: https://github.com/sidorares/node-mysql2/issues/649 https://github.com/sidorares/node-mysql2/issues/347
How i can turn <Buffer xx> to bool/int? https://dev.mysql.com/doc/refman/8.0/en/bit-type.html
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 16 (14 by maintainers)
Now, Whether the feature(typeCast) is supported ?
to avoid
delete payload.password
: