im stuck with this, thanks for your time, im trying to call a postgres fuction receiving a json array as param, im getting the following error qhen the exec the query:
error: bind message supplies 3 parameters, but prepared statement "" requires 1
im using pg for the connection an query, this is my code
create() {
var datajson=[];
var data=this.params.body;
if (Object.keys(data).length>1)
{
for (var i=0; i<Object.keys(data).length; i++)
{
datajson.push(data[i]);
console.log(JSON.stringify(data[i]));
}
}
var _this=this;
pg.connect(Nodal.my.Config.db.main, function(err, client, done) {
console.log('2');
if (err) {
console.log('3');
}
console.log("llamoexec"+JSON.stringify(datajson));
var query = {
// give the query a unique name
text: 'SELECT setProduct($1)',
values: datajson
}
client.query(query, function(err, result) {
console.log('4');
if (err) {
console.log('5'+err);
}
done();
});
});
}
Thank you so much for your help