JSONB will helps lots to use PostgreSQL internal functions. But, if you have JSON column only then you need to cast like following.
-
Array of Hashes
column_name:
[{a: 1}, {b: 2}, {c: 3}]
Model.where('column_name::jsonb @> ', [{a: 1}].to_json)
-
Select by json column and alias as Model method (TODO)
-
Select by pattern and alias as object (TODO)
Reference:
https://www.postgresql.org/docs/current/functions-json.html