I'm trying to remove int value from jsonb array of ints in json stored in jsonb value type in db.
I have a json value, like:
select '{"a":[1,3]}'::jsonb->'a'
?column?
----------
[1, 3]
(1 row)
And i want to remove '1' from it, like that:
select array_remove(ARRAY[1,1,2,3], 1);
array_remove
--------------
{2,3}
(1 row)
But if i do something like that:
select array_remove(array('{"a":[1,3]}'::jsonb->'a'), 1);
or:
select array_remove('{"a":[1,3]}'::jsonb->'a'::text::int[], 1);
I have an error like:
operator does not exist: jsonb -> integer[]
How can i cast json value to array to remove value from it?