1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
Since the customer is updating a value in a JSON doc, just use the built in PostgreSQL JSON functions
postgres=> CREATE TABLE test_json (a int, b jsonb);
CREATE TABLE
postgres=> INSERT INTO test_json
postgres-> VALUES (1, '{"key1": "abc"}'), (2, '{"key1": "xyz"}');
INSERT 0 2
postgres=> UPDATE test_json
postgres-> SET b = jsonb_set(b, '{key1}', (upper((b->'key1')::text))::jsonb);
UPDATE 2
postgres=> SELECT * FROM test_json;
a | b
---+-----------------
1 | {"key1": "ABC"}
2 | {"key1": "XYZ"}
(2 rows)
répondu il y a 4 ans
Contenus pertinents
- demandé il y a un an
- demandé il y a 4 mois
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 3 ans