Datahike is a durable Datalog database powered by an efficient Datalog query engine. This project started as a port of DataScript to the hitchhiker-tree. All DataScript tests are passing, but we are still working on the internals. Having said this we consider Datahike usable for medium sized projects, since DataScript is very mature and deployed in many applications and the hitchhiker-tree implementation is heavily tested through generative testing. We are building on the two projects and the storage backends for the hitchhiker-tree through konserve. We would like to hear experience reports and are happy if you join us.
You can find API documentation on cljdoc and articles on Datahike on our company's blog page.
We presented Datahike also at meetups,for example at:
Add to your dependencies:
We provide a small stable API for the JVM at the moment, but the on-disk schema is not fixed yet. We will provide a migration guide until we have reached a stable on-disk schema. Take a look at the ChangeLog before upgrading.
(require '[datahike.api :as d]) ;; use the filesystem as storage medium (def cfg {:store {:backend :file :path "/tmp/example"}}) ;; create a database at this place, per default configuration we enforce a strict ;; schema and keep all historical data (d/create-database cfg) (def conn (d/connect cfg)) ;; the first transaction will be the schema we are using ;; you may also add this within database creation by adding :initial-tx ;; to the configuration (d/transact conn [{:db/ident :name :db/valueType :db.type/string :db/cardinality :db.cardinality/one } {:db/ident :age :db/valueType :db.type/long :db/cardinality :db.cardinality/one }]) ;; lets add some data and wait for the transaction (d/transact conn [{:name "Alice", :age 20 } {:name "Bob", :age 30 } {:name "Charlie", :age 40 } {:age 15 }]) ;; search the data (d/q '[:find ?e ?n ?a :where [?e :name ?n] [?e :age ?a]] @conn) ;; => #{[3 "Alice" 20] [4 "Bob" 30] [5 "Charlie" 40]} ;; add new entity data using a hash map (d/transact conn {:tx-data [{:db/id 3 :age 25}]}) ;; if you want to work with queries like in ;; https://grishaev.me/en/datomic-query/, ;; you may use a hashmap (d/q {:query '{:find [?e ?n ?a ] :where [[?e :name ?n] [?e :age ?a]]} :args [@conn]}) ;; => #{[5 "Charlie" 40] [4 "Bob" 30] [3 "Alice" 25]} ;; query the history of the data (d/q '[:find ?a :where [?e :name "Alice"] [?e :age ?a]] (d/history @conn)) ;; => #{[20] [25]} ;; you might need to release the connection for specific stores (d/release conn) ;; clean up the database if it is not need any more (d/delete-database cfg)
The API namespace provides compatibility to a subset of Datomic functionality and should work as a drop-in replacement on the JVM. The rest of Datahike will be ported to core.async to coordinate IO in a platform-neutral manner.
Refer to the docs for more information:
For simple examples have a look at the projects in the examples folder.
Datahike provides similar functionality to Datomic and can be used as a drop-in replacement for a subset of it. The goal of Datahike is not to provide an open-source reimplementation of Datomic, but it is part of the replikativ toolbox aimed to build distributed data management solutions. We have spoken to many backend engineers and Clojure developers, who tried to stay away from Datomic just because of its proprietary nature and we think in this regard Datahike should make an approach to Datomic easier and vice-versa people who only want to use the goodness of Datalog in small scale applications should not worry about setting up and depending on Datomic.
Some differences are:
Datomic is a full-fledged scalable database (as a service) built from the authors of Clojure and people with a lot of experience. If you need this kind of professional support, you should definitely stick to Datomic.
Datahike's query engine and most of its codebase come from DataScript. Without the work on DataScript, Datahike would not have been possible. Differences to Datomic with respect to the query engine are documented there.
Pick Datahike if your app has modest requirements towards a typical durable database, e.g. a single machine and a few millions of entities at maximum. Similarly, if you want to have an open-source solution and be able to study and tinker with the codebase of your database, Datahike provides a comparatively small and well composed codebase to tweak it to your needs. You should also always be able to migrate to Datomic later easily.
Pick Datomic if you already know that you will need scalability later or if you need a network API for your database. There is also plenty of material about Datomic online already. Most of it applies in some form or another to Datahike, but it might be easier to use Datomic directly when you first learn Datalog.
Pick DataScript if you want the fastest possible query performance and do not have a huge amount of data. You can easily persist the write operations separately and use the fast in-memory index data structure of DataScript then. Datahike also at the moment does not support ClojureScript anymore, although we plan to recover this functionality.
ClojureScript support is planned and work in progress. Please see Discussions.
The database can be exported to a flat file with:
(require '[datahike.migrate :refer [export-db import-db]]) (export-db conn "/tmp/eavt-dump")
You must do so before upgrading to a Datahike version that has changed the
on-disk format. This can happen as long as we are arriving at version 1.0.0
and will always be communicated through the Changelog. After you have bumped the
Datahike version you can use
;; ... setup new-conn (recreate with correct schema) (import-db new-conn "/tmp/eavt-dump")
to reimport your data into the new format.
The datoms are stored in the CBOR format, enabling migration of binary data, such as the byte array data type now supported by Datahike. You can also use the export as a backup.
If you are upgrading from pre 0.1.2 where we have not had the migration code
yet, then just evaluate the datahike.migrate namespace manually in your
project before exporting.
Have a look at the change log for recent updates.
Instead of providing a static roadmap, we have moved to working closely with the community to decide what will be worked on next in a dynamic and interactive way.
How it works?
Go to Discussions and upvote all the ideas of features you would like to be added to Datahike. As soon as we have someone free to work on a new feature, we will address one with the most upvotes.
Of course, you can also propose ideas yourself - either by adding them to the Discussions or even by creating a pull request yourself. Please note thought that due to considerations about incompatibilities to earlier Datahike versions it might sometimes take a bit more time until your PR is integrated.
We are happy to provide commercial support with lambdaforge. If you are interested in a particular feature, please let us know.
Copyright © 2014–2023 Konrad Kühne, Christian Weilbach, Chrislain Razafimahefa, Timo Kramer, Judith Massa, Nikita Prokopov, Ryan Sundberg
Licensed under Eclipse Public License (see LICENSE).


全球首个AI音乐社区
音述AI是全球首个AI音乐社区,致力让每个人都能用音乐表达自我。音述AI提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。


一站式搞定所有学习需求
不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。


为AI短剧协作而生
专为AI短 剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。


能听懂你表达的视频模型
Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。


国内直接访问,限时3折
输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动


职场AI,就用扣子
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!


多风格AI绘画神器
堆友平台由阿里巴巴设计团队创建,作为 一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。


零代码AI应用开发平台
零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。


免费创建高清无水印Sora视频
Vora是一个免费创建高清无水印Sora视频的AI工具


最适合小白的AI自动化工作流平台
无需编码,轻松生成可复用、可变现的AI自动化工作流
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号