You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to merge a jsonb column with Lucid when an update is executed?
example: User table has a column details (json) when a user is created this column is populated with {first_name:"xxx", last_name:"xxx"}
Now I want a user to upload a profile picture, and append an avatar to the details column, resulting in {first_name:"xxx", last_name:"xxx", avatar:"path/to/image"}
Also, I want the user to update his first_name and last_name without losing the previously uploaded avatar, by just sending {"first_name": "bbb", "last_name": "ccc"} via body.
I know I can merge all this manually within the controller, but is there an alternative way to do it with User.query().where(...).update(...) only?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to merge a jsonb column with Lucid when an update is executed?
example: User table has a column
details
(json) when a user is created this column is populated with{first_name:"xxx", last_name:"xxx"}
Now I want a user to upload a profile picture, and append an
avatar
to the details column, resulting in{first_name:"xxx", last_name:"xxx", avatar:"path/to/image"}
Also, I want the user to update his first_name and last_name without losing the previously uploaded avatar, by just sending
{"first_name": "bbb", "last_name": "ccc"}
via body.I know I can merge all this manually within the controller, but is there an alternative way to do it with
User.query().where(...).update(...)
only?Beta Was this translation helpful? Give feedback.
All reactions