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.
(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 / aggregationssupabase.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 / ...(execute req)Runs the built request. Returns {:status :body :headers} or an
anomaly enriched with PostgREST error metadata.
Runs the built request. Returns `{:status :body :headers}` or an
anomaly enriched with PostgREST error metadata.(from c table)Starts a builder bound to table. Returns a request map you can
thread through filters / verbs / transforms before calling execute.
Returns an anomaly if the client is invalid.
Starts a builder bound to `table`. Returns a request map you can thread through filters / verbs / transforms before calling `execute`. Returns an anomaly if the client is invalid.
(schema req new-schema)Override the schema used for THIS request only. Defaults to the
client's :db :schema.
Override the schema used for THIS request only. Defaults to the client's `:db :schema`.
(with-custom-media-type req media-type)Override the accept header via a media-type keyword.
Valid keys: :default, :csv, :json, :openapi, :postgis,
:pgrst-plan, :pgrst-object, :pgrst-array.
Override the accept header via a media-type keyword. Valid keys: `:default`, `:csv`, `:json`, `:openapi`, `:postgis`, `:pgrst-plan`, `:pgrst-object`, `:pgrst-array`.
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 |