3 ms·
How close does it come to document databases when it comes to changing the JSON? Is it easy to increment a field, for example? Or add a property to an object?
by haasted 9y ago
How close does it come to document databases when it comes to changing the JSON? Is it easy to increment a field, for example? Or add a property to an object?
- e1g 9y agoPG JSON implementation is solid and supports nearly everything you want from a document database, with the added bonus of joins, queries, ACID, and tooling. However, syntax can be awkward at times - # Find a row by JSON property value select * from person where details->>'name' ilike '%james%' # check for property existence select * from person where details ? 'is_hidden' # Override a single property in a JSON field - update person set details = details || '{"phone":"911"}' # Alt increment existing value update person set details = jsonb_set(details, '{views}', (details->'views')+1) More examples at https://www.postgresql.org/docs/current/static/functions-json.html https://www.postgresql.org/docs/current/static/functions-jso...