clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1305706 fiddles created (20092 in the last week).

create table t (id int, data jsonb); insert into t values (1, '[ {"id":"1","status":"test status1","updatedAt":"1571145003"}, {"id":"2","status":"test status2","updatedAt":"1571145323"} ]');
1 rows affected
 hidden batch(es)


with ct as ( select id, ('{' || index-1 || ',updatedAt}')::text[] as path from t, jsonb_array_elements(data) with ordinality arr(c, index) ) --select * from ct --update t --set data = jsonb_set(data, ct.path, '"1571150000"', false) --from ct --where ct.id = t.id;
ERROR: syntax error at end of input LINE 13: --where ct.id = t.id; ^
 hidden batch(es)


select * from t;
id data
1 [{"id": "1", "status": "test status1", "updatedAt": "1571145003"}, {"id": "2", "status": "test status2", "updatedAt": "1571145323"}]
 hidden batch(es)


with ct as ( select id, jsonb_array_elements(data) dt from t ) , ct2 as ( select id, jsonb_set(dt, '{updatedAt}', '"1571150000"', false) dt2 from ct ) update t set data = (select jsonb_agg(dt2) from ct2 where ct2.id = t.id);
1 rows affected
 hidden batch(es)


select * from t;
id data
1 [{"id": "1", "status": "test status1", "updatedAt": "1571150000"}, {"id": "2", "status": "test status2", "updatedAt": "1571150000"}]
 hidden batch(es)