Updating A Nested Field Inside A JSONB Column #928
Unanswered
asim-sansi
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Your input data is missing the column, hence the error. Perhaps try this: const cs = new pgp.helpers.ColumnSet(
[
"?id",
{
name: 'rental_history',
mod: ':raw',
def: null, // provide a default for when the column is missing
init: (c) =>
`jsonb_set(rental_history, '{income,all}', '{"all": ${c.source.income}}'::jsonb)`,
},
],
{
table: { table: 'assets' }
}
); |
Beta Was this translation helpful? Give feedback.
2 replies
-
Maybe your use of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an assets table that keeps a jsonb
rental_history
column. The column has a fixed structure and looks like thisI'm trying to update the 'all' field in both
income
&hours
sub fields. What I have come up with so far is thisThe
updateArray
looks like thisWhen I run the script it returns this error
column "rental_history" does not exist
Any help would be appreciated ? Thanks
Version : "pg-promise": "^11.0.2"
Beta Was this translation helpful? Give feedback.
All reactions