With the help of the Datahike cli we provide the possibility to run Datahike as a babashka pod.
A babashka pod is a way to use Datahike in babashka without Datahike being built into the babashka binary. When you don't want to run a whole JVM for a little script you can use babashka and write your script in your preferred language. Babashka already has ways to persist data to other databases but Datahike adds the possibility to write to a durable datalog database.
You can use the official babashka pod-registry to download the latest version of Datahike as a pod and run it with babashka.
Please run bb ni-cli inside the datahike repository. You'll need GraalVM-JDK installed with native-compile on your path, babashka and Clojure.
This feature is not used in production so far. Please try it and open issues on GitHub if you find a problem.
(ns pod
(:require [babashka.pods :as pods]))
(pods/load-pod 'replikativ/datahike "0.7.1628") ;; Please check for the latest version
(require '[datahike.pod :as d])
(def config {:store {:backend :file
:path "/tmp/bb-datahike-pod"}
:keep-history? true
:schema-flexibility :read})
(d/delete-database config)
(d/create-database config)
(def conn (d/connect config))
(d/transact conn [{:name "Alice", :age 20}
{:name "Bob", :age 30}
{:name "Charlie", :age 40}
{:age 15}])
(def db (d/db conn))
(d/q '[:find ?e ?n ?a
:where
[?e :name ?n]
[?e :age ?a]]
db)
(release-db db)
(d/pull (d/db conn) '[*] 3)
(with-db [db (db conn)]
(q {:query '{:find [?e ?a ?v]
:where
[[?e ?a ?v]]}}
db))
Can you improve this documentation? These fine people already did:
Christian Weilbach, Coby Tamayo & Timo KramerEdit on GitHub
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 |