I was wondering if there was a way to call the ability to unnest an array utilizing a columnSet with PG Promise? So for example, I have a req.body call to a textfield that is split by commas on javascript back end. For example:
var juneDates = req.body.junedates.split(',')
But I can't seem to figure out how to utilize a columnSet to utilize Postgres unnest feature. This is what I have:
const cs = new pgp.helpers.ColumnSet(
[
{
name: "attrib_id",
},
{
name: "value",
skip(col) {
return col.value === null || col.value === undefined;
},
},
{
name: "response_id",
},
],
{
table: "formquestionresponse",
}
);
var juneDates = req.body.junedates.split(',')
values = {
attrib_id: 1,
value: juneDates;
response_id: 2
}
const query = pgp.helpers.insert(values, cs);
const recordsResponse = db.none(query);
I can't get the skip functionality to work either, but I know that's due to it only working on a update call. Is there anyway to do a skip for a insert or do I have to utilize JS to do that?
Thank you so much.
question from:
https://stackoverflow.com/questions/66051077/how-to-execute-a-unnest-array-in-a-columnset-with-pgpromise 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…