Liking cljdoc? Tell your friends :D

supabase.postgrest

Idiomatic Clojure builder for the PostgREST API.

Builds a request map via thread-first, then execute runs it through supabase.core.http and returns either a response or an anomaly.

Quick start

(require '[supabase.core.client :as sc]
         '[supabase.postgrest :as pg])

(def client (sc/make-client "https://abc.supabase.co" "anon-key"))

;; SELECT
(-> (pg/from client "users")
    (pg/select "*")
    (pg/eq "active" true)
    (pg/order "created_at")
    (pg/limit 10)
    (pg/execute))

;; INSERT
(-> (pg/from client "users")
    (pg/insert {:email "a@b.com"})
    (pg/execute))

;; UPDATE filtered
(-> (pg/from client "users")
    (pg/eq "id" 42)
    (pg/update {:name "Jane"})
    (pg/execute))

;; DELETE filtered
(-> (pg/from client "users")
    (pg/eq "id" 42)
    (pg/delete)
    (pg/execute))

;; RPC
(-> (pg/rpc client "my_function" {:arg 1})
    (pg/execute))

See sub-namespaces for the full API:

  • supabase.postgrest.filters — eq / gt / like / contains / and / or / not / ...
  • supabase.postgrest.query — select / embed / insert / upsert / update / delete / rpc / aggregations
  • supabase.postgrest.transform— order / limit / range / single / csv / explain / returning / ...
  • supabase.postgrest.encode — pg-array / pg-range / pg-bool / ->iso (type coercion helpers)
Idiomatic Clojure builder for the PostgREST API.

Builds a request map via thread-first, then `execute` runs it through
`supabase.core.http` and returns either a response or an anomaly.

## Quick start

    (require '[supabase.core.client :as sc]
             '[supabase.postgrest :as pg])

    (def client (sc/make-client "https://abc.supabase.co" "anon-key"))

    ;; SELECT
    (-> (pg/from client "users")
        (pg/select "*")
        (pg/eq "active" true)
        (pg/order "created_at")
        (pg/limit 10)
        (pg/execute))

    ;; INSERT
    (-> (pg/from client "users")
        (pg/insert {:email "a@b.com"})
        (pg/execute))

    ;; UPDATE filtered
    (-> (pg/from client "users")
        (pg/eq "id" 42)
        (pg/update {:name "Jane"})
        (pg/execute))

    ;; DELETE filtered
    (-> (pg/from client "users")
        (pg/eq "id" 42)
        (pg/delete)
        (pg/execute))

    ;; RPC
    (-> (pg/rpc client "my_function" {:arg 1})
        (pg/execute))

See sub-namespaces for the full API:
  - `supabase.postgrest.filters`  — eq / gt / like / contains / and / or / not / ...
  - `supabase.postgrest.query`    — select / embed / insert / upsert / update / delete / rpc / aggregations
  - `supabase.postgrest.transform`— order / limit / range / single / csv / explain / returning / ...
  - `supabase.postgrest.encode`   — pg-array / pg-range / pg-bool / ->iso (type coercion helpers)
raw docstring

supabase.postgrest.encode

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))
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))
raw docstring

supabase.postgrest.error

PostgREST-specific anomaly enrichment.

PostgREST error bodies carry extra fields — message, hint, code, details — that callers want surfaced. This module decorates a core.error anomaly with those fields under the :postgrest/* namespace and, for a handful of well-known codes, refines the anomaly category.

PostgREST-specific anomaly enrichment.

PostgREST error bodies carry extra fields — `message`, `hint`, `code`,
`details` — that callers want surfaced. This module decorates a
`core.error` anomaly with those fields under the `:postgrest/*` namespace
and, for a handful of well-known codes, refines the anomaly category.
raw docstring

supabase.postgrest.filters

Filter builders for PostgREST queries.

Every fn takes a request map (from supabase.postgrest/from) and returns it with a query-string filter appended.

Composite filters

all-of / any-of accept a nested vector DSL:

[[:gt "age" 18]
 [:eq "status" "active"]
 [:and [[:lt "salary" 5000]
        [:eq "role" "junior"]]]
 [:not [:eq "deleted" true]]]
Filter builders for PostgREST queries.

Every fn takes a request map (from `supabase.postgrest/from`) and
returns it with a query-string filter appended.

## Composite filters

`all-of` / `any-of` accept a nested vector DSL:

    [[:gt "age" 18]
     [:eq "status" "active"]
     [:and [[:lt "salary" 5000]
            [:eq "role" "junior"]]]
     [:not [:eq "deleted" true]]]
raw docstring

supabase.postgrest.query

Query verbs (select/insert/upsert/update/delete) + rpc + aggregations.

Query verbs (select/insert/upsert/update/delete) + rpc + aggregations.
raw docstring

supabase.postgrest.specs

Malli schemas for PostgREST builder option maps.

Validates caller-supplied opts only. Filter values pass through to the URL — PostgREST validates them server-side.

Malli schemas for PostgREST builder option maps.

Validates caller-supplied opts only. Filter values pass through to the
URL — PostgREST validates them server-side.
raw docstring

supabase.postgrest.transform

Result-shape transforms: order, limit, range, single, csv, geojson, explain, rollback, returning.

Result-shape transforms: order, limit, range, single, csv, geojson,
explain, rollback, returning.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close