You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgreSQL offers various methods to work with jsonb fields efficiently.
Here’s a pseudocode example illustrating a model and how to filter using a jsonb field:
classTestUserProfile < Marten::Modelfield:id,:big_int,primary_key: true,auto: truefield:user,:one_to_one,to: TestUser,related: :profilefield:bio,:text,blank: true,null: truefield:groups,:jsonb# This represents an array of strings, e.g., ["admin", "user", "manager"]end# Filtering profiles where groups include an intersection with ["admin", "ukraine"]TestUserProfile.filter(groups__intersection: ["admin","ukraine"])# -> 'WHERE groups ?| array["admin", "ukraine"]'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
PostgreSQL offers various methods to work with
jsonb
fields efficiently.Here’s a pseudocode example illustrating a model and how to filter using a
jsonb
field:Beta Was this translation helpful? Give feedback.
All reactions