Liking cljdoc? Tell your friends :D

stratus-db.client

The ClojureScript client of stratus (Clojars com.stratus-db/client), for server-side callers (Node): transit-json requests (keywords, UUIDs and instants native), gzipped transit-json responses (fetch inflates them). Every function returns a js/Promise.

The hosted API (https://api.stratus-db.com), with an API key:

(def conn (client/connect "https://api.stratus-db.com" {:api-key (.-STRATUS_API_KEY js/process.env)})) (-> (client/create-db! conn {:name "orders" :primary-key :order/id}) (.then (fn [{:keys [id]}] (client/transact! conn id {:tx [{:order/id (client/squuid) :total 5}]}))))

Databases are at <url>/v1/dbs/<id>/..., the key sent as "Authorization: Bearer <key>". Busy databases answer 429: retried with backoff. The high-level functions resolve to the response body and reject with an ex-info {:status :error :message} on an error; call gives {:status :body} as it is. The query language: docs/query.md.

The ClojureScript client of stratus (Clojars com.stratus-db/client), for server-side callers
(Node): transit-json requests (keywords, UUIDs and instants native), gzipped transit-json
responses (fetch inflates them). Every function returns a js/Promise.

The hosted API (https://api.stratus-db.com), with an API key:

  (def conn (client/connect "https://api.stratus-db.com" {:api-key (.-STRATUS_API_KEY js/process.env)}))
  (-> (client/create-db! conn {:name "orders" :primary-key :order/id})
      (.then (fn [{:keys [id]}] (client/transact! conn id {:tx [{:order/id (client/squuid) :total 5}]}))))

Databases are at <url>/v1/dbs/<id>/..., the key sent as "Authorization: Bearer <key>". Busy
databases answer 429: retried with backoff. The high-level functions resolve to the response
body and reject with an ex-info {:status :error :message} on an error; call gives
{:status :body} as it is. The query language: docs/query.md.
raw docstring

await-indexcljs

(await-index conn id att)
(await-index conn id att timeout-ms)

A promise resolving when att's index is :ready (to the db info), rejecting when it is :failed or after timeout-ms (default 60000).

A promise resolving when att's index is :ready (to the db info), rejecting when it is
:failed or after timeout-ms (default 60000).
raw docstring

callcljs

(call url method path)
(call url method path body)
(call url method path body opts)

method path body (a value, sent as transit) to url: a promise of {:status :body}, retried while throttled (429), and while API Gateway refuses a brand-new key (its own 403 Forbidden, for up to :new-key-wait-ms, default 120000). opts: :api-key, :retries (default 200).

method path body (a value, sent as transit) to url: a promise of {:status :body}, retried
while throttled (429), and while API Gateway refuses a brand-new key (its own 403 Forbidden,
for up to :new-key-wait-ms, default 120000). opts: :api-key, :retries (default 200).
raw docstring

call-catalogcljs

(call-catalog conn method path)
(call-catalog conn method path body)

method path body to the catalog: a promise of {:status :body}.

method path body to the catalog: a promise of {:status :body}.
raw docstring

call-dbcljs

(call-db conn id method path)
(call-db conn id method path body)

method path body to database id (<url>/v1/dbs/<id>): a promise of {:status :body}.

method path body to database id (<url>/v1/dbs/<id>): a promise of {:status :body}.
raw docstring

connectcljs

(connect url)
(connect url opts)

A connection to the service at url (its base URL). opts: :api-key, and call's.

A connection to the service at url (its base URL). opts: :api-key, and call's.
raw docstring

create-db!cljs

(create-db! conn spec)

Creates a database {:name :primary-key}: its record.

Creates a database {:name :primary-key}: its record.
raw docstring

create-key!cljs

(create-key! conn)
(create-key! conn {:keys [name scope]})

A new key: {:key (shown once) :record}. :scope - database ids it may reach (default all).

A new key: {:key (shown once) :record}. :scope - database ids it may reach (default all).
raw docstring

db-by-namecljs

(db-by-name conn name)

The record of the live database named name (names are unique among live databases; a deleted one's name is free again). Fails 404 when there is none.

The record of the live database named name (names are unique among live databases; a deleted
one's name is free again). Fails 404 when there is none.
raw docstring

db-infocljs

(db-info conn id)

{:id :primary-key :t :checkpoint-t :indexes :index-errors}.

{:id :primary-key :t :checkpoint-t :indexes :index-errors}.
raw docstring

db-recordcljs

(db-record conn id)

Database id's record, deleted or not.

Database id's record, deleted or not.
raw docstring

dbscljs

(dbs conn)
(dbs conn {:keys [deleted?]})

The live databases' records, oldest first; deleted ones too with {:deleted? true}. A record: {:id :name :primary-key :created :state :deleted :storage :fork-of}.

The live databases' records, oldest first; deleted ones too with {:deleted? true}. A record:
{:id :name :primary-key :created :state :deleted :storage :fork-of}.
raw docstring

decodecljs

(decode s)

The value of transit-json s.

The value of transit-json s.
raw docstring

delete-db!cljs

(delete-db! conn id)

drop-index!cljs

(drop-index! conn id att)

Drops att's index (an attribute, or a multi-attribute index's vector).

Drops att's index (an attribute, or a multi-attribute index's vector).
raw docstring

encodecljs

(encode x)

x as transit-json.

x as transit-json.
raw docstring

excise!cljs

(excise! conn id {:keys [rows attributes]})

Excises :rows (primary keys) and :attributes ([{:pk :att}]) - erasure: gone from the current state, its indexes and history (and the database's forks): {:t :rows :attributes}.

Excises :rows (primary keys) and :attributes ([{:pk :att}]) - erasure: gone from the current
state, its indexes and history (and the database's forks): {:t :rows :attributes}.
raw docstring

fork!cljs

(fork! conn id)
(fork! conn id opts)

Forks database id: a new database, this one as of transaction :t (default its latest), recorded in both logs: the fork's record ({:id :fork-of {:db :t} ...}).

Forks database id: a new database, this one as of transaction :t (default its
latest), recorded in both logs: the fork's record ({:id :fork-of {:db :t} ...}).
raw docstring

historycljs

(history conn id)
(history conn id {:keys [from limit]})

One page of database id's history from t :from (default 1), at most :limit entries (default 100, at most 1000): {:entries [{:t :type :time :commands ...}] :next t-or-nil}. A transaction's entry carries its caller's ARN, its time and its commands ({:pk :att :value :op}): the audit trail.

One page of database id's history from t :from (default 1), at most :limit entries (default
100, at most 1000): {:entries [{:t :type :time :commands ...}] :next t-or-nil}. A
transaction's entry carries its caller's ARN, its time and its commands ({:pk :att :value
:op}): the audit trail.
raw docstring

history-allcljs

(history-all conn id)
(history-all conn id opts)

Every history entry from :from on, following :next: a promise of a vector.

Every history entry from :from on, following :next: a promise of a vector.
raw docstring

keys-listcljs

(keys-list conn)

The account's keys' records (no secrets).

The account's keys' records (no secrets).
raw docstring

pullcljs

(pull conn id pks)
(pull conn id pks opts)

The rows of pks, in order, nil for a missing one; opts {:as-of t} as they stood after transaction t.

The rows of pks, in order, nil for a missing one; opts {:as-of t} as they stood after
transaction t.
raw docstring

querycljs

(query conn id q)

One page of query q (docs/query.md): {:rows :next :t}. q's :as-of t reads the database as it stood after transaction t.

One page of query q (docs/query.md): {:rows :next :t}. q's :as-of t reads the database as it
stood after transaction t.
raw docstring

query-allcljs

(query-all conn id q)

Every row of query q, following :next: a promise of a vector.

Every row of query q, following :next: a promise of a vector.
raw docstring

rename-db!cljs

(rename-db! conn id name)

request-index!cljs

(request-index! conn id att)
(request-index! conn id att opts)

Requests att's index: {:att :state} (:building until built). att is an attribute, or a vector of 2 to 8 for a multi-attribute index (its rows keyed by the tuple of their values; queried by tuple predicates), with opts :required - the attributes a row needs a value of to be in it.

Requests att's index: {:att :state} (:building until built). att is an attribute, or a
vector of 2 to 8 for a multi-attribute index (its rows keyed by the tuple of their values;
queried by tuple predicates), with opts :required - the attributes a row needs a value of to
be in it.
raw docstring

revoke-key!cljs

(revoke-key! conn key-id)

Revokes key key-id: its record.

Revokes key key-id: its record.
raw docstring

set-history-retention!cljs

(set-history-retention! conn id days)

Sets how long database id keeps its history: days (whole days, 30 to 36500), or nil to keep it forever. History past the window is dropped at the database's next checkpoints: {:days :t}.

Sets how long database id keeps its history: days (whole days, 30 to 36500), or nil to keep
it forever. History past the window is dropped at the database's next checkpoints: {:days :t}.
raw docstring

squuidcljs

(squuid)

A sequential UUID: created later in this process, it sorts after every earlier one, even within a millisecond or when the clock steps back (a full sequence carries into the time).

A sequential UUID: created later in this process, it sorts after every earlier one, even
within a millisecond or when the clock steps back (a full sequence carries into the time).
raw docstring

transact!cljs

(transact! conn id tx)

{:tx [maps] :retract [maps] :delete [pks] :tx-id id}: {:t :pks}. Every map carries its primary key (squuid makes new ones). :tx-id (optional; a UUID or a string) makes a retry safe: if a transaction with that id is already committed, nothing is applied and the answer is the first one's with :duplicate true (409 :tx-id-reused if it had other commands). :match (optional; row maps: a primary key and attributes) is a compare-and-set: each attribute must hold that value now (nil: absent; numbers across types, as queries' :=), else nothing is applied and it rejects with 409 :conflict.

{:tx [maps] :retract [maps] :delete [pks] :tx-id id}: {:t :pks}. Every map carries its
primary key (squuid makes new ones). :tx-id (optional; a UUID or a string) makes a retry
safe: if a transaction with that id is already committed, nothing is applied and the answer
is the first one's with :duplicate true (409 :tx-id-reused if it had other commands).
:match (optional; row maps: a primary key and attributes) is a compare-and-set: each
attribute must hold that value now (nil: absent; numbers across types, as queries' :=),
else nothing is applied and it rejects with 409 :conflict.
raw docstring

versioncljs

The client's version: the pom's (clients/cljs/pom.xml), which release-cljs.yml checks against it.

The client's version: the pom's (clients/cljs/pom.xml), which release-cljs.yml checks against it.
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