I have a jsonb field in the table. I want to update an individual key value, So I am using jsonb_set method. The key that I want to update is in a variable.
Here is the jsonb object that I want to update
{"yes":5,"total_votes":6,"no":1}
and the key variable vote_to is yes.
Here is how I am trying
update polls set result = jsonb_set(result, ('{'||vote_to||'}'),vote_count::text::jsonb) where id=_poll_id;
And the error is
ERROR: function jsonb_set(jsonb, text, jsonb) does not exist
LINE 1: update polls set result = jsonb_set(result, ('{'||vote_to||'...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
And how can I update two keys in one shot? And also vote_count is an integer so i need it to double cast to make jsonb
vote_count::text::jsonb
Is there any other way to do this?