Heroku - NodeJS - Send json with data from postgres database

326
February 17, 2017, at 01:49 AM

I'm starting with Heroku and NodeJS and Postgres database.

I have several tables named table1, table2, table3, ...table27. All tables have the same structure 10 columns.

I'm trying to build a webservice to send as json all data from these tables.

I tried several ways, usync async modules or without but without success. I fected some unwanted data (basically, database structure). For example:

JSON-result: {"command":"SELECT","rowCount":0,"oid":null,"rows":[],"fields":[{"name":"id","tableID":945497,"columnID":1,"dataTypeID":23,"dataTypeSize":4,"dataTypeModifier":-1,"format":"text"},{"name":"code_event","tableID":945497,"columnID":2,"dataTypeID":23,"dataTypeSize":4,"dataTypeModifier":-1,"format":"text"},{"name":"version","tableID":945497,"columnID":3,"dataTypeID":23,"dataTypeSize":4,"dataTypeModifier":-1,"format":"text"},{"name":"used","tableID":945497,"columnID":4,"dataTypeID":23,"dataTypeSize":4,"dataTypeModifier":-1,"format":"text"},{"name":"reference1","tableID":945497,"columnID":5,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"reference2","tableID":945497,"columnID":6,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"reference3","tableID":945497,"columnID":7,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"reference4","tableID":945497,"columnID":8,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"reference5","tableID":945497,"columnID":9,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"label1","tableID":945497,"columnID":10,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"label2","tableID":945497,"columnID":11,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"label3","tableID":945497,"columnID":12,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"label4","tableID":945497,"columnID":13,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"label5","tableID":945497,"columnID":14,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":104,"format":"text"},{"name":"export_action","tableID":945497,"columnID":15,"dataTypeID":1043,"dataTypeSize":-1,"dataTypeModifier":54,"format":"text"}],"_parsers":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"rowAsArray":false}

I tried these code: Node js call function, that access mysql database and returns json result, multiple times

How can I get a proper json with following data? {table1: {row1, row2...}, table2:{row1,row2...}....}

Rent Charter Buses Company
READ ALSO
Disable 308 Redirect caching with node.js

Disable 308 Redirect caching with node.js

How do I disable browsers default Redirect caching behavior using nodejs?

444
Is it possible to run React project without npm start?

Is it possible to run React project without npm start?

I'm in a big troubleWorking in a part time in a company they're looking for a new web technology to build "web-component" in their website

511
`npm install` doesn't install anything?

`npm install` doesn't install anything?

What's the reason of this problem? I installed node by nvm

471
How to update an array element following one of its properties

How to update an array element following one of its properties

I want to update my locations array basing on unique element specified by $sort parameterI'm using findByIdAndUpdate method for mongoose

308