supabase-rb-rb
Database

Use a custom filter

Escape hatch — apply a raw PostgREST operator + criteria string.

The low-level primitive every other filter is built on. Pass the PostgREST operator (eq, like, cs, fts, etc.) and the criteria (the right-hand side of the operator.criteria pair) verbatim. Use this when PostgREST grows a new operator before this library exposes a named helper, or when you need to construct the operator string dynamically.

Every named filter on the builder (eq, gt, like, …) is a thin wrapper that calls filter with the matching operator constant.

Signature

builder.filter(column, operator, criteria)

Parameters

NameTypeRequiredDescription
columnString / SymbolRequiredColumn name. Sanitized before being used as the query-string key.
operatorStringRequiredPostgREST operator — one of eq, neq, gt, gte, lt, lte, like, ilike, is, in, cs, cd, ov, sl, sr, nxl, nxr, adj, fts, plfts, phfts, wfts, like(all), like(any), ilike(all), ilike(any).
criteriaStringRequiredThe right-hand side of the operator. Format depends on the operator: a scalar for eq/gt/…, parenthesized list for in (e.g. "(1,2,3)"), braced list for cs (e.g. "{ruby,supabase}"), tsquery string for fts.

Returns

Returns
self (FilterRequestBuilder)

The same builder for chaining. If not_ was called immediately before, the operator is prefixed with not. and the negation flag is cleared.

Example — equivalent of eq

# These two calls produce identical wire requests.
supabase.from("countries").select("*").eq("id", 1).execute
supabase.from("countries").select("*").filter("id", "eq", 1).execute

# Wire: ?id=eq.1

Example — in with a parenthesized criteria string

supabase
  .from("countries")
  .select("*")
  .filter("id", "in", "(1,2,3)")
  .execute

# Wire: ?id=in.(1,2,3)

Example — contains (cs) with a braced criteria string

# Equivalent to .contains("tags", ["ruby", "supabase"])
supabase
  .from("posts")
  .select("*")
  .filter("tags", "cs", "{ruby,supabase}")
  .execute

# Wire: ?tags=cs.{ruby,supabase}

Example — full-text search with config

supabase
  .from("articles")
  .select("*")
  .filter("body", "fts(english)", "ruby & postgrest")
  .execute

# Wire: ?body=fts(english).ruby%20%26%20postgrest

Example — negate with not_

supabase
  .from("orders")
  .select("*")
  .not_.filter("status", "eq", "cancelled")
  .execute

# Wire: ?status=not.eq.cancelled

String-syntax escape hatch

The operator and criteria follow PostgREST's wire format — criteria is the literal string PostgREST receives after the operator's dot separator. Refer to the PostgREST operators docs when picking the criteria shape.

On this page