With the help of the Datahike cli we provide the possibility to run Datahike as ababashka 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.
We plan to provide the native binaries of Datahike via GitHub-Releases in the future. Unfortunately you have to compile it yourself for now. To do that you need to clone the Datahike repository, have babashka and clojure as well as a JDK installed.
Then please run bb ni-cli
inside the datahike repository.
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 "./dthk")
(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 is a website building & hosting documentation for Clojure/Script libraries
× close