var query = `select * from map_balances where balance_userid = $1 AND balance_vendorid = $2 AND balance_amount >= $3`
var values = [accesstoken,token,arr.map(e=>e.vid),arr.map(e=>e.amt)];
client.query(query,{arr:values},async(err,projectdata)=>{
if (err) {
res.json({success:false,message:err.message,responsecode:-1});
} else {
res.json({success:true,message:projectdata.rowCount,responsecode:200});
}
});
here arr=[{"vid": 636,"amt": "21","add": "123123"},{"vid": 636,"amt": "21","add": "123123"},{"vid": 636,"amt": "21","add": "123123"}]
will be like this from client
here I am trying to the get data from db, arr is an array which contains no.of objects in each object "amt" is there and it should be greater then the balance in db
I am using postgres and tried some other types as well still not working
2
Answers
and install npm i pg-format...
If you pass the array json itself to postgreSQL it would look like: