'Firebird query returns Buffer

This is my first time connecting to a Firebird database from Node JS. I'm using the "node-firebird" package. Everything seems to work fine. But I get these <Buffer 50 5a 41> tags back in my object.

This is what my query returns:

[
  {
    ARTICULO_ID: 422698,
    NOMBRE: 'CONEXION 3/4 HHP-S',
    ES_ALMACENABLE: <Buffer 53>,
    ES_JUEGO: <Buffer 4e>,
    ESTATUS: <Buffer 41>,
    CAUSA_SUSP: null,
    FECHA_SUSP: null,
    IMPRIMIR_COMP: <Buffer 4e>,
    PERMITIR_AGREGAR_COMP: null,
    LINEA_ARTICULO_ID: 785107
  }
]

And here is my code:

const pool = require("./util/database");

const query = "SELECT * FROM articulos WHERE nombre='CONEXION 3/4 HHP-S'";

pool.get(function (err, db) {
  if (err) throw err;

  db.query(query, function (err, result) {
    if (err) {
      console.log(err);
    }
    console.log(result);

    db.detach();
  });
});

pool.destroy();

Edit: The columns that return a Buffer are all string datatypes. The solution was buffer.toString()



Solution 1:[1]

It seems that the query was only returning Buffers for string datatypes. I used this code to fix it:

//After query returns a result.

const product = result[0]; //Pull out the first result

for (let key in product) {
   currentDataset = product[key];
   if (Buffer.isBuffer(currentDataset) === true) {
      product[key] = currentDataset.toString('utf-8');
   }
} 

My problem was lack of understanding how Buffers work. Thanks to @Mark Rotteveel for the advice.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dtremp