I have a metadata
column of type jsonb
.
I know how to check whether it contains a specific key:
obj = Model.create
obj.metadata = {"foo"=>"1", "bar"=>{"baz"=>{"qux"=>2}}}
obj.save
Model.where("(metadata->'bar') IS NOT NULL") # returns obj
I wonder, how would I check if there is baz
key in obj.metadata['bar']
and, if I had, for deeper nested keys?