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 / insert / upsert / update / delete / rpc / aggregations
  • supabase.postgrest.transform— order / limit / range / single / csv / explain / returning / ...
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 / insert / upsert / update / delete / rpc / aggregations
  - `supabase.postgrest.transform`— order / limit / range / single / csv / explain / returning / ...
raw docstring

supabase.postgrest.error

PostgREST-specific anomaly enrichment.

PostgREST error bodies carry extra fields — hint, code, details — that callers want surfaced. This module wraps core.error anomalies with those extras.

PostgREST-specific anomaly enrichment.

PostgREST error bodies carry extra fields — `hint`, `code`, `details` —
that callers want surfaced. This module wraps `core.error` anomalies
with those extras.
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