我有一个postgreSQL数据库,它以json格式存储对表的所有更改,new_val和old_val
看起来像这样
new_val
{"id":6,"id_item_type":7,"id_contact_as_producer":2,"id_contact_as_owner": 2,"comment":"3213","id_item_status":1,"imageurl":null,"id_station":2,"audit_id":null}";"
old_val
{"id":6,"id_item_type":7,"id_contact_as_producer":2,"id_contact_as_owner":2,"comment":"3213","id_item_status":1,"imageurl":null,"id_station":null,"audit_id":null}"
我可以使用sql命令
在pgadmin中轻松查询SELECT * FROM audit.history WHERE new_val ->> 'id_item_type' = '7'
但是当我尝试从带有PG的nodejs查询它时,它就会挂起。我认为这是因为PG将其输入为字符串
var query = client.query('SELECT * FROM audit.history WHERE new_val ->> 'id_item_type' = '7'',
function (err, result) {
done();
});
所以我的问题基本上是,如何在Node中使用查询来自PG的数据库给我相同的结果?