Today I Learned

hashrocket A Hashrocket project

Remove key/value from jsonb data structure

If you store jsonb in your postgres database, you will find yourself manipulating json data periodically in postgres.

Removing a key/value from a jsonb object is very simple, just use the subtraction operator.

> select '{"a": 1, "b": 2}'::jsonb - 'a';
 {"b": 2}
(1 row)
See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.