I have data that looks like this:
id name blocks
1 Test 1 [{"name": "Bob", "type": "INFO", "title": "CFO"}, {"type": "FOOTER"}]
2 Another [{"name": "Bob", "type": "INFO", "title": "Manager"}, {"type": "FOOTER"}]
3 Final [{"id": 22, "type": "IMAGE"}]
The user may want to change their name across all rows, so I'd need to have a Postgres JSON version of:
UPDATE blocks SET name = 'New Name' WHERE type = 'INFO';
How do I write a query that will search these arrays of objects for a specific type key of value "INFO"? The big catch here is that these objects can be in any order in the array. So the INFO block isn't always necessarily at index 0.
nameyou want to update. Name Filed or Name tag in array elementstype = 'INFO'