Heroku - NodeJS - 使用postgres数据库

时间:2017-02-16 16:16:09

标签: node.js postgresql heroku

我从Heroku和NodeJS以及Postgres数据库开始。

我有几个名为table1,table2,table3,... table27的表。 所有表都有10列相同的结构。

我正在尝试构建一个Web服务,以json的形式发送来自这些表的所有数据。

我尝试了几种方法,usync异步模块或没有但没有成功。我发了一些不需要的数据(基本上是数据库结构)。例如:

  

JSON-结果:   {"命令":" SELECT"" rowCount时":0," OID":空,"行&#34 ;: [],"字段":[{"名称":" ID"" TABLEID":945497," ColumnID的&#34 ;:1," dataTypeID":23," dataTypeSize&#34:4," dataTypeModifier": - 1,"格式":&#34 ;文本"},{"名称":" code_event"" TABLEID":945497," ColumnID的":2&# 34; dataTypeID":23," dataTypeSize&#34:4," dataTypeModifier": - 1,"格式":"文本"} ,{"名称":"版本"" TABLEID":945497," ColumnID的":3," dataTypeID" :23," dataTypeSize&#34:4," dataTypeModifier": - 1,"格式":"文本"},{"名称":"使用"" TABLEID":945497," ColumnID的&#34:4," dataTypeID":23,&#34 ; dataTypeSize&#34:4," dataTypeModifier": - 1,"格式":"文本"},{"名称":& #34;参考值1"" TABLEID":945497," ColumnID的":5," dataTypeID":1043," dataTypeSiz E": - 1," dataTypeModifier":104,"格式":"文本"},{"名称":&# 34;给定2"" TABLEID":945497," ColumnID的":6," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式":"文本"},{"名称":" reference3" " TABLEID":945497," ColumnID的":7," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式":"文本"},{"名称":" reference4"" TABLEID& #34;:945497," ColumnID的":8," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104 "格式":"文本"},{"名称":" reference5"" TABLEID":945497, " ColumnID的":9," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式& #34;:"文本"},{"名称":" label1的"" TABLEID":945497," ColumnID的&# 34;:10," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式":"文本"},{"名称":" LABEL2" " TABLEID":945497," ColumnID的":11," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式":"文本"},{"名称":" LABEL3"" TABLEID& #34;:945497," ColumnID的":12," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104 "格式":"文本"},{"名称":" label4"" TABLEID":945497, " ColumnID的":13," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式& #34;:"文本"},{"名称":" label5"" TABLEID":945497," ColumnID的&# 34;:14," dataTypeID":1043," dataTypeSize": - 1," dataTypeModifier":104,"格式":&# 34;文本"},{"名称":" export_action"" TABLEID":945497," ColumnID的":15,& #34; dataTypeID":1043," dataTypeSize": - 1," dataTy peModifier":54,"格式":"文本"}]," _parsers":[NULL,NULL,NULL,NULL,NULL,NULL,NULL ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL]" rowAsArray":假}

我试过这些代码: Node js call function, that access mysql database and returns json result, multiple times

如何使用以下数据获得正确的json? {table1:{row1,row2 ...},table2:{row1,row2 ...} ....}

0 个答案:

没有答案