Implementing a new backend to use for datahike does not require much effort as there are only a handful of methods for multimethods must be created. In order to keep things tidy, we have agreed on some conventions:
datahike-{backendname}.core
.As an example, you may have a look at the implementation of our Postgres backend, i.e. datahike-postgres.
Here, we provide a basic template for a backend implementation. Following are bracketed text pieces defining placeholder values, you should replace as follows:
keyword
to identify your backend on request. At this moment, datahike ships with backends identified by :mem
and :file
, so do not use those.keyword
identifying an index to be used as default for your backend. So far, you can choose between the following:
:datahike.index/hitchhiker-tree
:datahike.index/persistent-set
clojure.spec
definition for configuration validationYou may add any configuration attributes to the store configuration. Only :backend
is mandatory which refers to backendID.
In your core.clj:
(ns datahike-{backendname}.core
(:require [datahike.store :as s]
;; your imports
))
(defmethod s/empty-store {backendID} [config]
;; your implementation
)
(defmethod s/delete-store {backendID} [config]
;; your implementation
)
(defmethod connect-store {backendID} [config]
;; your implementation
)
(defmethod release-store {backendID} [config store]
;; your implementation
)
(defmethod scheme->index {backendID} [_]
{indexID}
)
(defmethod default-config {backendID} [config]
;; your implementation for default values e.g. from env vars or values from best practices
)
(defmethod config-spec {backendID} [_] {configSpec})
Can you improve this documentation? These fine people already did:
Timo Kramer, Konrad Kühne & JudithEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close