Pre-encoders for complex PostgreSQL column types, for use as filter values or RPC arguments. These render the literal forms PostgREST expects; PostgREST itself validates them server-side.
(require '[supabase.postgrest :as pg]
'[supabase.postgrest.encode :as enc])
(-> (pg/from c "reservations")
(pg/eq "during" (enc/pg-range start end))
(pg/contains "tags" (enc/pg-array ["vip" "weekend"]))
(pg/execute))
Pre-encoders for complex PostgreSQL column types, for use as filter
values or RPC arguments. These render the literal forms PostgREST expects;
PostgREST itself validates them server-side.
## Example
(require '[supabase.postgrest :as pg]
'[supabase.postgrest.encode :as enc])
(-> (pg/from c "reservations")
(pg/eq "during" (enc/pg-range start end))
(pg/contains "tags" (enc/pg-array ["vip" "weekend"]))
(pg/execute))(->iso t)Encodes a timestamp as ISO-8601. Accepts java.time.Instant,
java.util.Date, or a string (passed through).
Encodes a timestamp as ISO-8601. Accepts `java.time.Instant`, `java.util.Date`, or a string (passed through).
(pg-array xs)Encodes xs as a PostgreSQL array literal: {a,b,c}. Elements with
special characters are quoted; nil elements become NULL.
Encodes `xs` as a PostgreSQL array literal: `{a,b,c}`. Elements with
special characters are quoted; `nil` elements become `NULL`.(pg-bool b)Encodes a boolean as "true"/"false", for is-style filters.
Encodes a boolean as `"true"`/`"false"`, for `is`-style filters.
(pg-range lo hi)(pg-range lo hi bounds)Encodes a range literal. Default bounds [lo,hi) (inclusive low,
exclusive high); pass bounds as one of "[)", "[]", "()",
"(]". Either endpoint may be nil for an unbounded side. Timestamp
endpoints are coerced via ->iso.
Encodes a range literal. Default bounds `[lo,hi)` (inclusive low, exclusive high); pass `bounds` as one of `"[)"`, `"[]"`, `"()"`, `"(]"`. Either endpoint may be `nil` for an unbounded side. Timestamp endpoints are coerced via [[->iso]].
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |