I'm new to node.js and javascript studies and I'm trying to build a backend to fetch information from a Firebird database.
I am using some dependencies that are in a course that I am following. My project as 'express', 'nodemon', 'node-firebird'.
Using the following structure:
The code in my server.js file is:
const firebird = require('node-firebird');
const express = require('express');
const app = express();
//const teste;
const options = {
host: '127.0.0.1',
database: 'C:/Users/alexandrefelix.GREENCANE/Desktop/Aulas/backend-firebird/src/TGA.FDB',
user: 'SYSDBA',
password: 'masterkey',
};
app.get('/', (req, res) => {
// 5 = the number is count of opened sockets
var pool = firebird.pool(5, options);
// Get a free pool
pool.get(function(err, db) {
if (err)
throw err;
// db = DATABASE
db.query('SELECT * FROM GEMPRESA', function(err, result) {
// IMPORTANT: release the pool connection
console.log(result);
db.detach();
});
});
// Destroy pool
pool.destroy();
return res.json({ message: 'Hello World!'});
});
app.listen(3333);
So when I run the code, and access 'localhost: 3333' in the browser it presents my test message (Hello World) but in the console, it presents the varchar fields as buffers:
CITY: Buffer 55 42 45 52 41 42 41
When it should be:
CITY: "UBERABA"
My question is why the returning JSON is displaying VARCHAR fields this way and how do I put the result of a column within a variable.