javascript - node-postgres: Update more than one record at once -
i'm building app in node.js using node-postgres. don't know how update more 1 record @ once.
here code:
var status = 20; var id = [23,12,43]; pool.connect(function(err, client, done) { if(err) { done(); console.log(err); return res.status(500).send(json({ success: false, data: err})); } client.query("update mydatabase set status=($1) id in($2);", [status,id]);
but i've got problem - console:
events.js:160 throw er; // unhandled 'error' event ^
error: invalid input syntax integer: "23,12,43"
what can in case? kind of data use? length of var id not same every time.
greetings, rafaĆ
edit: think change of data work in javascript, input must 23,12,43, instead [23,12,43] don't know how make that.
it looks want use any
:
client.query("update mydatabase set status=($1) id = any($2);", [status,id]);
this due postgresql itself, not library: see this , this
see question: oracle: '= any()' vs. 'in ()'
Comments
Post a Comment