Liking cljdoc? Tell your friends :D

biff.datalevin.adapter

Biff 2 database adapter for Datalevin.

Provides a biff.core module that:

  • starts a Datalevin connection
  • implements biff.core's key-value store interface (:biff.core/kv-get, :biff.core/kv-set, :biff.core/kv-list)
  • provides :biff.core/wrap-db-snapshot for consistent reads
  • calls :biff.core/on-tx after transactions
  • generates biff.graph resolvers from a Datalevin schema
  • provides biff.fx handlers for queries and transactions

Example:

(def modules [(biff.fx/module) (biff.graph/module) (biff.datalevin.adapter/module {:biff.datalevin/db-path "data/myapp" :biff.datalevin/schema my-schema})])

(def start-order [:biff.datalevin/module])

See https://github.com/jacobobryant/biff/blob/master/docs/db-adapters.md

Biff 2 database adapter for Datalevin.

Provides a biff.core module that:

  - starts a Datalevin connection
  - implements biff.core's key-value store interface
    (:biff.core/kv-get, :biff.core/kv-set, :biff.core/kv-list)
  - provides :biff.core/wrap-db-snapshot for consistent reads
  - calls :biff.core/on-tx after transactions
  - generates biff.graph resolvers from a Datalevin schema
  - provides biff.fx handlers for queries and transactions

Example:

  (def modules
    [(biff.fx/module)
     (biff.graph/module)
     (biff.datalevin.adapter/module
      {:biff.datalevin/db-path "data/myapp"
       :biff.datalevin/schema my-schema})])

  (def start-order
    [:biff.datalevin/module])

See https://github.com/jacobobryant/biff/blob/master/docs/db-adapters.md
raw docstring

execute-txclj

(execute-tx ctx tx-data)

Executes a Datalevin transaction, returning the transaction report.

Supports the special values :db/now and :db/uuid. :biff.core/on-tx is called after the transaction (via a connection listener).

Executes a Datalevin transaction, returning the transaction report.

Supports the special values :db/now and :db/uuid. :biff.core/on-tx is
called after the transaction (via a connection listener).
sourceraw docstring

fx-handlersclj

A biff.fx handlers map. Contains :biff.datalevin.fx/q and :biff.datalevin.fx/execute-tx.

A biff.fx handlers map. Contains :biff.datalevin.fx/q and
:biff.datalevin.fx/execute-tx.
sourceraw docstring

kv-getclj

(kv-get ctx namespace* key*)

Implementation of :biff.core/kv-get.

Returns the value for key* in namespace*, or nil if unset.

Implementation of :biff.core/kv-get.

Returns the value for `key*` in `namespace*`, or nil if unset.
sourceraw docstring

kv-listclj

(kv-list ctx namespace*)
(kv-list ctx namespace* key-prefix)

Implementation of :biff.core/kv-list.

Returns a sorted vector of keys in namespace*. If key-prefix is set, only keys beginning with it are returned.

Implementation of :biff.core/kv-list.

Returns a sorted vector of keys in `namespace*`. If `key-prefix` is set,
only keys beginning with it are returned.
sourceraw docstring

kv-schemaclj

Datalevin schema for the biff.core key-value store.

Datalevin schema for the biff.core key-value store.
sourceraw docstring

kv-setclj

(kv-set ctx namespace* key* value)

Implementation of :biff.core/kv-set.

Sets key* in namespace* to value. A nil value deletes the key. Values are serialized with pr-str, so they must be readable by clojure.edn/read-string.

Implementation of :biff.core/kv-set.

Sets `key*` in `namespace*` to `value`. A nil `value` deletes the key.
Values are serialized with pr-str, so they must be readable by
clojure.edn/read-string.
sourceraw docstring

make-resolversclj

(make-resolvers schema)

Returns a sequence of biff.graph resolvers, one for each entity type in schema (a Datalevin schema map).

Entity types are determined by attribute namespaces, e.g. all :user/* attrs belong to the :user entity type. The primary key is :<ns>/id if it exists, otherwise the first unique attribute in the namespace.

Ref attributes are returned as joins. The target entity type is inferred from the attribute name: :session/user refers to :user/id and :user/pet-id refers to :pet/id. For refs whose names don't imply their target (e.g. :group/members), set :biff.datalevin/ref in the schema entry:

:group/members {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many :biff.datalevin/ref :user/id}

If a ref attribute ends in -id, that attribute is also returned as a scalar containing the referenced primary key value.

Returns a sequence of biff.graph resolvers, one for each entity type in
`schema` (a Datalevin schema map).

Entity types are determined by attribute namespaces, e.g. all :user/* attrs
belong to the :user entity type. The primary key is :<ns>/id if it exists,
otherwise the first unique attribute in the namespace.

Ref attributes are returned as joins. The target entity type is inferred
from the attribute name: :session/user refers to :user/id and :user/pet-id
refers to :pet/id. For refs whose names don't imply their target (e.g.
:group/members), set :biff.datalevin/ref in the schema entry:

  :group/members {:db/valueType      :db.type/ref
                  :db/cardinality    :db.cardinality/many
                  :biff.datalevin/ref :user/id}

If a ref attribute ends in -id, that attribute is also returned as a scalar
containing the referenced primary key value.
sourceraw docstring

moduleclj

(module {:biff.datalevin/keys [db-path schema opts snapshot?]})

Returns a biff.core module for Datalevin. Module ID is :biff.datalevin/module.

Options: :biff.datalevin/db-path - Path to the Datalevin database directory (required) :biff.datalevin/schema - Datalevin schema map :biff.datalevin/opts - Additional options passed to d/get-conn :biff.datalevin/snapshot? - Set to false to skip :biff.core/wrap-db-snapshot (default true)

Other modules may contribute schema by including a :biff.datalevin/schema key in their module map.

On start, opens a connection and adds to the system map:

:biff.datalevin/conn - The Datalevin connection :biff.core/kv-get - biff.core key-value store :biff.core/kv-set :biff.core/kv-list :biff.core/wrap-db-snapshot - Provides consistent reads (unless :biff.datalevin/snapshot? is false)

Returns a biff.core module for Datalevin. Module ID is
:biff.datalevin/module.

Options:
  :biff.datalevin/db-path   - Path to the Datalevin database directory (required)
  :biff.datalevin/schema    - Datalevin schema map
  :biff.datalevin/opts      - Additional options passed to d/get-conn
  :biff.datalevin/snapshot? - Set to false to skip :biff.core/wrap-db-snapshot
                              (default true)

Other modules may contribute schema by including a :biff.datalevin/schema
key in their module map.

On start, opens a connection and adds to the system map:

  :biff.datalevin/conn          - The Datalevin connection
  :biff.core/kv-get             - biff.core key-value store
  :biff.core/kv-set
  :biff.core/kv-list
  :biff.core/wrap-db-snapshot   - Provides consistent reads (unless
                                  :biff.datalevin/snapshot? is false)
sourceraw docstring

qclj

(q ctx query & args)

Queries the Datalevin database.

ctx is a system map containing :biff.datalevin/conn (or a Datalevin connection or database value).

Example: (q ctx '[:find ?e :where [?e :user/email "a@b.com"]])

Queries the Datalevin database.

`ctx` is a system map containing :biff.datalevin/conn (or a Datalevin
connection or database value).

Example:
  (q ctx '[:find ?e :where [?e :user/email "a@b.com"]])
sourceraw docstring

submit-txclj

(submit-tx ctx tx-data)

Alias for execute-tx.

Alias for execute-tx.
sourceraw 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