Match at least one filter
Apply a grouped OR clause using PostgREST's `or=(…)` string syntax.
Filter rows where any of the supplied sub-filters match. The filters argument is a PostgREST filter string — exactly the body of a or=( … ) query-string parameter — passed through verbatim. reference_table: scopes the OR to an embedded resource for foreign-table filtering.
The method is named or_ because or is a reserved word in Ruby's parser.
Signature
builder.or_(filters, reference_table: nil)Parameters
| Name | Type | Required | Description |
|---|---|---|---|
filters | String | Required | PostgREST filter string. Each sub-filter is operator.value separated by commas: e.g. "id.eq.1,name.eq.Algeria". Wrap nested ORs in or(...) and ANDs in and(...) — the string is passed through unchanged. |
reference_table | String | Optional | Embedded resource name. When set, PostgREST applies the OR to the embedded relation: foreign_table.or=(...). Used to filter joined rows. |
Returns
The same builder for chaining.
Example — match rows by id OR by name
supabase
.from("countries")
.select("id, name")
.or_("id.eq.1,name.eq.Algeria")
.execute
# Wire: ?or=(id.eq.1,name.eq.Algeria)Example — combine multiple comparisons
supabase
.from("orders")
.select("*")
.or_("status.eq.refunded,total.gt.10000")
.executeExample — nested and inside an or
PostgREST string syntax allows arbitrarily nested logical groups. Each clause is a filter string.
supabase
.from("subscriptions")
.select("*")
.or_("plan.eq.enterprise,and(plan.eq.pro,seats.gte.10)")
.execute
# Wire: ?or=(plan.eq.enterprise,and(plan.eq.pro,seats.gte.10))Example — not inside an or
supabase
.from("users")
.select("*")
.or_("role.eq.admin,not.is.deleted_at.null")
.executeExample — OR applied to an embedded resource
# Posts with at least one comment that is featured OR has more than 100 likes.
supabase
.from("posts")
.select("id, title, comments(*)")
.or_("featured.eq.true,likes.gt.100", reference_table: "comments")
.execute
# Wire: ?comments.or=(featured.eq.true,likes.gt.100)Pass PostgREST's string syntax directly
There is no per-operator DSL — write the raw PostgREST filter string (column.operator.value separated by commas). See the PostgREST logical-operators docs for the full grammar.