I have a postgreSQL database that stores all changes to table in json format, new_val and old_val
It looks like this
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}"
I can query this easily in pgadmin with the sql command
SELECT * FROM audit.history WHERE new_val ->> 'id_item_type' = '7'
But when I try to query it from nodejs with PG it just hangs. I think it is because PG gets it input as a string
var query = client.query('SELECT * FROM audit.history WHERE new_val ->> 'id_item_type' = '7'',
function (err, result) {
done();
});
So my question is basically, how can I use query the db from PG in Node to give me the same result?