3 ms·
> That being stated, I'll agree that similar mechanisms for the JSON fields would make sense for Postgres to consider in the future. I think they are working o
by jeltz 13y ago
> That being stated, I'll agree that similar mechanisms for the JSON fields would make sense for Postgres to consider in the future.
I think they are working on adding modification functions for hstore right now, and the plan is to also add them to JSON once that is done.
You could easily implement your own such functions right now, since PostgreSQL already support atomic modifications in of columns with UPDATE with no overwriting. This statement is safe to use to increment a counter.
UPDATE c SET counter = counter + 1 WHERE id = 42;
And since that is the case this should also be safe.
UPDATE c SET data = my_json_array_append(data, 7) WHERE id = 42;
There is nothing magical about "+".