Posgres JSONb notes

Postgres JSONb notes

I find one of the most annoying parts of working with jsonb columns in postgres is remembering the syntax. Below are some notes, mostly for myself. (Yes reading the postgres docs is probably a better call, I'm writing this for me.) ¯\_(ツ)_/¯

Also how great is Sports, Not Heavy Crime? It's pretty great.

Field existence in a column

SELECT * from phlerbs WHERE jsonb_column ? 'field_name'

Retrieving a value

SELECT * from phlerbs WHERE jsonb_column->'field_name'

Read more

https://www.postgresql.org/docs/9.5/functions-json.html