【发布时间】:2021-10-26 19:36:12
【问题描述】:
我正在使用 PostgreSQL,我正在使用 Nodejs 和 PG 包。我有这些表:
request_tbl:
req_id | customer_id | details
----+--------------------------------------
1 | 1 | something
customers_tbl:
cust_id | full_name | age
----+--------------------------------------
1 | tarik hh | 23
我需要一个在将其转换为 json 后给出此输出的查询。
这是一个左连接,但我需要将连接的列作为对象。
[
{
"req_id":"1" ,
"details":"something" ,
"customer":{
"cust_id":"1",
"full_name":"tarik hh"
}
}
]
【问题讨论】:
-
避免在问题正文中发布问题的解决方案。您可以将其发布为答案。
标签: node.js json postgresql pg