I have table with jsonb column "Details":
{"Type": "VIP", "Quantity": 1}
I want update column, using query that copies value from "Type" field to new one "Subscription" and change value "VIP"->2. Exp below:
{"Type": 2, "Quantity": 1, "Subscription": "VIP"}
I have tried script but received error "Can't extract scalar value"
Update "Media" set "Details" = jsonb_set("Details", '{Subscription}'::text[],
(select res.value from jsonb_array_elements("Details" -> 'Type') as res), true)
What is wrong? Please, help to find a solution.