UPDATE jsontesting
SET jsondata = jsondata || '["newString"]'::jsonb
WHERE id = 7;
remove
UPDATE jsontesting
SET jsondata = jsondata - "newString"
WHERE id = 7;
nested append
UPDATE jsontesting
SET jsondata = jsonb_set(
jsondata::jsonb,
array['nestedfield'],
(jsondata->'nestedfield')::jsonb || '["newString"]'::jsonb)
WHERE id = 7;
Splice by index
UPDATE ${table}
SET ${col} = ${col} - (
SELECT i
FROM generate_series(0, jsonb_array_length(${col}) - 1) AS i
WHERE (${col}->i->'id' = '"${id}"')
)
WHERE ${table}.id = '${where}'::uuid