module

Lustra::SQL::JSONB

Instance methods

jsonb_all_exists?(field, keys : Array(String))

jsonb ?& operator Do all of these array strings exist as top-level keys?

Source
jsonb_any_exists?(field, keys : Array(String))

jsonb ?| operator Do any of these array strings exist as top-level keys?

Source
jsonb_eq(field, key, value)

Test equality using the @> operator

jsonb_eq("data.sub.key", "value")

=> data @> '{"sub": {"key": "value"}}'

Source
jsonb_exists?(field, value)

Does the string exist as a top-level key within the JSON value?

Source
jsonb_k2h(key : String, value : JSONBKey) : JSONBHash

Transform a key to a hash

Source
jsonb_resolve(field, arr : Array(String), cast = nil) : String
Source
jsonb_resolve(field, key : String, cast = nil)

Return text selector for the field/key :

jsonb_text("data", "sub.key").like("user%")
# => "data->'sub'->>'key' LIKE 'user%'"
Source

Nested types