datahike-browser-tests 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +405 -0
- package/.circleci/scripts/gen_ci.clj +194 -0
- package/.cirrus.yml +60 -0
- package/.clj-kondo/babashka/sci/config.edn +1 -0
- package/.clj-kondo/babashka/sci/sci/core.clj +9 -0
- package/.clj-kondo/config.edn +95 -0
- package/.dir-locals.el +2 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/1-bug-report.yml +68 -0
- package/.github/ISSUE_TEMPLATE/2-feature-request.yml +28 -0
- package/.github/ISSUE_TEMPLATE/config.yml +6 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/native-image.yml +84 -0
- package/LICENSE +203 -0
- package/README.md +273 -0
- package/bb/deps.edn +9 -0
- package/bb/resources/github-fingerprints +3 -0
- package/bb/resources/native-image-tests/run-bb-pod-tests.clj +162 -0
- package/bb/resources/native-image-tests/run-libdatahike-tests +12 -0
- package/bb/resources/native-image-tests/run-native-image-tests +74 -0
- package/bb/resources/native-image-tests/run-python-tests +22 -0
- package/bb/resources/native-image-tests/testconfig.attr-refs.edn +6 -0
- package/bb/resources/native-image-tests/testconfig.edn +5 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/bb/resources/template/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/bb/resources/template/pom.xml +22 -0
- package/bb/src/tools/build.clj +132 -0
- package/bb/src/tools/clj_kondo.clj +32 -0
- package/bb/src/tools/deploy.clj +26 -0
- package/bb/src/tools/examples.clj +19 -0
- package/bb/src/tools/npm.clj +100 -0
- package/bb/src/tools/python.clj +14 -0
- package/bb/src/tools/release.clj +94 -0
- package/bb/src/tools/test.clj +148 -0
- package/bb/src/tools/version.clj +47 -0
- package/bb.edn +269 -0
- package/benchmark/src/benchmark/cli.clj +195 -0
- package/benchmark/src/benchmark/compare.clj +157 -0
- package/benchmark/src/benchmark/config.clj +316 -0
- package/benchmark/src/benchmark/measure.clj +187 -0
- package/benchmark/src/benchmark/store.clj +190 -0
- package/benchmark/test/benchmark/measure_test.clj +156 -0
- package/build.clj +30 -0
- package/config.edn +49 -0
- package/deps.edn +138 -0
- package/dev/sandbox.clj +82 -0
- package/dev/sandbox.cljs +127 -0
- package/dev/sandbox_benchmarks.clj +27 -0
- package/dev/sandbox_client.clj +87 -0
- package/dev/sandbox_transact_bench.clj +109 -0
- package/dev/user.clj +79 -0
- package/doc/README.md +96 -0
- package/doc/adl/README.md +6 -0
- package/doc/adl/adr-000-adr.org +28 -0
- package/doc/adl/adr-001-attribute-references.org +15 -0
- package/doc/adl/adr-002-build-tooling.org +54 -0
- package/doc/adl/adr-003-db-meta-data.md +52 -0
- package/doc/adl/adr-004-github-flow.md +40 -0
- package/doc/adl/adr-XYZ-template.md +30 -0
- package/doc/adl/index.org +3 -0
- package/doc/assets/datahike-logo.svg +3 -0
- package/doc/assets/datahiking-invoice.org +85 -0
- package/doc/assets/hhtree2.png +0 -0
- package/doc/assets/network_topology.svg +624 -0
- package/doc/assets/perf.png +0 -0
- package/doc/assets/schema_mindmap.mm +132 -0
- package/doc/assets/schema_mindmap.svg +970 -0
- package/doc/assets/temporal_index.mm +74 -0
- package/doc/backend-development.md +78 -0
- package/doc/bb-pod.md +89 -0
- package/doc/benchmarking.md +360 -0
- package/doc/bindings/edn-conversion.md +383 -0
- package/doc/cli.md +162 -0
- package/doc/cljdoc.edn +27 -0
- package/doc/cljs-support.md +133 -0
- package/doc/config.md +406 -0
- package/doc/contributing.md +114 -0
- package/doc/datalog-vs-sql.md +210 -0
- package/doc/datomic_differences.md +109 -0
- package/doc/development/pull-api-ns.md +186 -0
- package/doc/development/pull-frame-state-diagram.jpg +0 -0
- package/doc/distributed.md +566 -0
- package/doc/entity_spec.md +92 -0
- package/doc/gc.md +273 -0
- package/doc/java-api.md +808 -0
- package/doc/javascript-api.md +421 -0
- package/doc/libdatahike.md +86 -0
- package/doc/logging_and_error_handling.md +43 -0
- package/doc/norms.md +66 -0
- package/doc/schema-migration.md +85 -0
- package/doc/schema.md +287 -0
- package/doc/storage-backends.md +363 -0
- package/doc/store-id-refactoring.md +596 -0
- package/doc/time_variance.md +325 -0
- package/doc/unstructured.md +167 -0
- package/doc/versioning.md +261 -0
- package/examples/basic/README.md +19 -0
- package/examples/basic/deps.edn +6 -0
- package/examples/basic/docker-compose.yml +13 -0
- package/examples/basic/src/examples/core.clj +60 -0
- package/examples/basic/src/examples/schema.clj +155 -0
- package/examples/basic/src/examples/store.clj +60 -0
- package/examples/basic/src/examples/time_travel.clj +185 -0
- package/examples/java/.settings/org.eclipse.core.resources.prefs +3 -0
- package/examples/java/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/examples/java/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/examples/java/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/examples/java/README.md +162 -0
- package/examples/java/pom.xml +62 -0
- package/examples/java/src/main/java/examples/QuickStart.java +115 -0
- package/examples/java/src/main/java/examples/SchemaExample.java +148 -0
- package/examples/java/src/main/java/examples/TimeTravelExample.java +121 -0
- package/flake.lock +27 -0
- package/flake.nix +27 -0
- package/http-server/datahike/http/middleware.clj +75 -0
- package/http-server/datahike/http/server.clj +269 -0
- package/java/src/datahike/java/Database.java +274 -0
- package/java/src/datahike/java/Datahike.java +281 -0
- package/java/src/datahike/java/DatahikeGeneratedTest.java +349 -0
- package/java/src/datahike/java/DatahikeTest.java +370 -0
- package/java/src/datahike/java/EDN.java +170 -0
- package/java/src/datahike/java/IEntity.java +11 -0
- package/java/src/datahike/java/Keywords.java +161 -0
- package/java/src/datahike/java/SchemaFlexibility.java +52 -0
- package/java/src/datahike/java/Util.java +219 -0
- package/karma.conf.js +19 -0
- package/libdatahike/compile-cpp +7 -0
- package/libdatahike/src/datahike/impl/LibDatahikeBase.java +203 -0
- package/libdatahike/src/datahike/impl/libdatahike.clj +59 -0
- package/libdatahike/src/test_cpp.cpp +61 -0
- package/npm-package/PUBLISHING.md +140 -0
- package/npm-package/README.md +226 -0
- package/npm-package/package.template.json +34 -0
- package/npm-package/test-isomorphic.ts +281 -0
- package/npm-package/test.js +557 -0
- package/npm-package/typescript-test.ts +70 -0
- package/package.json +16 -0
- package/pydatahike/README.md +569 -0
- package/pydatahike/pyproject.toml +91 -0
- package/pydatahike/setup.py +42 -0
- package/pydatahike/src/datahike/__init__.py +134 -0
- package/pydatahike/src/datahike/_native.py +250 -0
- package/pydatahike/src/datahike/_version.py +2 -0
- package/pydatahike/src/datahike/database.py +722 -0
- package/pydatahike/src/datahike/edn.py +311 -0
- package/pydatahike/src/datahike/py.typed +0 -0
- package/pydatahike/tests/conftest.py +17 -0
- package/pydatahike/tests/test_basic.py +170 -0
- package/pydatahike/tests/test_database.py +51 -0
- package/pydatahike/tests/test_edn_conversion.py +299 -0
- package/pydatahike/tests/test_query.py +99 -0
- package/pydatahike/tests/test_schema.py +55 -0
- package/resources/clj-kondo.exports/io.replikativ/datahike/config.edn +5 -0
- package/resources/example_server.edn +4 -0
- package/shadow-cljs.edn +56 -0
- package/src/data_readers.clj +7 -0
- package/src/datahike/api/impl.cljc +176 -0
- package/src/datahike/api/specification.cljc +633 -0
- package/src/datahike/api/types.cljc +261 -0
- package/src/datahike/api.cljc +41 -0
- package/src/datahike/array.cljc +99 -0
- package/src/datahike/cli.clj +166 -0
- package/src/datahike/cljs.cljs +6 -0
- package/src/datahike/codegen/cli.clj +406 -0
- package/src/datahike/codegen/clj_kondo.clj +291 -0
- package/src/datahike/codegen/java.clj +403 -0
- package/src/datahike/codegen/naming.cljc +33 -0
- package/src/datahike/codegen/native.clj +559 -0
- package/src/datahike/codegen/pod.clj +488 -0
- package/src/datahike/codegen/python.clj +838 -0
- package/src/datahike/codegen/report.clj +55 -0
- package/src/datahike/codegen/typescript.clj +262 -0
- package/src/datahike/codegen/validation.clj +145 -0
- package/src/datahike/config.cljc +294 -0
- package/src/datahike/connections.cljc +16 -0
- package/src/datahike/connector.cljc +265 -0
- package/src/datahike/constants.cljc +142 -0
- package/src/datahike/core.cljc +297 -0
- package/src/datahike/datom.cljc +459 -0
- package/src/datahike/db/interface.cljc +119 -0
- package/src/datahike/db/search.cljc +305 -0
- package/src/datahike/db/transaction.cljc +937 -0
- package/src/datahike/db/utils.cljc +338 -0
- package/src/datahike/db.cljc +956 -0
- package/src/datahike/experimental/unstructured.cljc +126 -0
- package/src/datahike/experimental/versioning.cljc +172 -0
- package/src/datahike/externs.js +31 -0
- package/src/datahike/gc.cljc +69 -0
- package/src/datahike/http/client.clj +188 -0
- package/src/datahike/http/writer.clj +79 -0
- package/src/datahike/impl/entity.cljc +218 -0
- package/src/datahike/index/interface.cljc +93 -0
- package/src/datahike/index/persistent_set.cljc +469 -0
- package/src/datahike/index/utils.cljc +44 -0
- package/src/datahike/index.cljc +32 -0
- package/src/datahike/js/api.cljs +172 -0
- package/src/datahike/js/api_macros.clj +22 -0
- package/src/datahike/js.cljs +163 -0
- package/src/datahike/json.cljc +209 -0
- package/src/datahike/lru.cljc +146 -0
- package/src/datahike/migrate.clj +39 -0
- package/src/datahike/norm/norm.clj +245 -0
- package/src/datahike/online_gc.cljc +252 -0
- package/src/datahike/pod.clj +155 -0
- package/src/datahike/pull_api.cljc +325 -0
- package/src/datahike/query.cljc +1945 -0
- package/src/datahike/query_stats.cljc +88 -0
- package/src/datahike/readers.cljc +62 -0
- package/src/datahike/remote.cljc +218 -0
- package/src/datahike/schema.cljc +228 -0
- package/src/datahike/schema_cache.cljc +42 -0
- package/src/datahike/spec.cljc +101 -0
- package/src/datahike/store.cljc +80 -0
- package/src/datahike/tools.cljc +308 -0
- package/src/datahike/transit.cljc +80 -0
- package/src/datahike/writer.cljc +239 -0
- package/src/datahike/writing.cljc +362 -0
- package/src/deps.cljs +1 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/insert.cljc +76 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/upsert.cljc +128 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree.cljc +213 -0
- package/test/datahike/backward_compatibility_test/src/backward_test.clj +37 -0
- package/test/datahike/integration_test/config_record_file_test.clj +14 -0
- package/test/datahike/integration_test/config_record_test.clj +14 -0
- package/test/datahike/integration_test/depr_config_uri_test.clj +15 -0
- package/test/datahike/integration_test/return_map_test.clj +62 -0
- package/test/datahike/integration_test.cljc +67 -0
- package/test/datahike/norm/norm_test.clj +124 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/01-transact-basic-characters.edn +2 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/02 add occupation.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/checksums.edn +12 -0
- package/test/datahike/norm/resources/simple-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/checksums.edn +6 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/norm/resources/tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-fn-test/second/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/test/api_test.cljc +895 -0
- package/test/datahike/test/array_test.cljc +40 -0
- package/test/datahike/test/attribute_refs/datoms_test.cljc +140 -0
- package/test/datahike/test/attribute_refs/db_test.cljc +42 -0
- package/test/datahike/test/attribute_refs/differences_test.cljc +515 -0
- package/test/datahike/test/attribute_refs/entity_test.cljc +89 -0
- package/test/datahike/test/attribute_refs/pull_api_test.cljc +320 -0
- package/test/datahike/test/attribute_refs/query_find_specs_test.cljc +59 -0
- package/test/datahike/test/attribute_refs/query_fns_test.cljc +130 -0
- package/test/datahike/test/attribute_refs/query_interop_test.cljc +47 -0
- package/test/datahike/test/attribute_refs/query_not_test.cljc +193 -0
- package/test/datahike/test/attribute_refs/query_or_test.cljc +137 -0
- package/test/datahike/test/attribute_refs/query_pull_test.cljc +156 -0
- package/test/datahike/test/attribute_refs/query_rules_test.cljc +176 -0
- package/test/datahike/test/attribute_refs/query_test.cljc +241 -0
- package/test/datahike/test/attribute_refs/temporal_search.cljc +22 -0
- package/test/datahike/test/attribute_refs/transact_test.cljc +220 -0
- package/test/datahike/test/attribute_refs/utils.cljc +128 -0
- package/test/datahike/test/cache_test.cljc +38 -0
- package/test/datahike/test/components_test.cljc +92 -0
- package/test/datahike/test/config_test.cljc +158 -0
- package/test/datahike/test/core_test.cljc +105 -0
- package/test/datahike/test/datom_test.cljc +44 -0
- package/test/datahike/test/db_test.cljc +54 -0
- package/test/datahike/test/entity_spec_test.cljc +159 -0
- package/test/datahike/test/entity_test.cljc +103 -0
- package/test/datahike/test/explode_test.cljc +143 -0
- package/test/datahike/test/filter_test.cljc +75 -0
- package/test/datahike/test/gc_test.cljc +159 -0
- package/test/datahike/test/http/server_test.clj +192 -0
- package/test/datahike/test/http/writer_test.clj +86 -0
- package/test/datahike/test/ident_test.cljc +32 -0
- package/test/datahike/test/index_test.cljc +345 -0
- package/test/datahike/test/insert.cljc +125 -0
- package/test/datahike/test/java_bindings_test.clj +6 -0
- package/test/datahike/test/listen_test.cljc +41 -0
- package/test/datahike/test/lookup_refs_test.cljc +266 -0
- package/test/datahike/test/lru_test.cljc +27 -0
- package/test/datahike/test/migrate_test.clj +297 -0
- package/test/datahike/test/model/core.cljc +376 -0
- package/test/datahike/test/model/invariant.cljc +142 -0
- package/test/datahike/test/model/rng.cljc +82 -0
- package/test/datahike/test/model_test.clj +217 -0
- package/test/datahike/test/nodejs_test.cljs +262 -0
- package/test/datahike/test/online_gc_test.cljc +475 -0
- package/test/datahike/test/pod_test.clj +369 -0
- package/test/datahike/test/pull_api_test.cljc +474 -0
- package/test/datahike/test/purge_test.cljc +144 -0
- package/test/datahike/test/query_aggregates_test.cljc +101 -0
- package/test/datahike/test/query_find_specs_test.cljc +52 -0
- package/test/datahike/test/query_fns_test.cljc +523 -0
- package/test/datahike/test/query_interop_test.cljc +47 -0
- package/test/datahike/test/query_not_test.cljc +189 -0
- package/test/datahike/test/query_or_test.cljc +158 -0
- package/test/datahike/test/query_pull_test.cljc +147 -0
- package/test/datahike/test/query_rules_test.cljc +248 -0
- package/test/datahike/test/query_stats_test.cljc +218 -0
- package/test/datahike/test/query_test.cljc +984 -0
- package/test/datahike/test/schema_test.cljc +424 -0
- package/test/datahike/test/specification_test.cljc +30 -0
- package/test/datahike/test/store_test.cljc +78 -0
- package/test/datahike/test/stress_test.cljc +57 -0
- package/test/datahike/test/time_variance_test.cljc +518 -0
- package/test/datahike/test/tools_test.clj +134 -0
- package/test/datahike/test/transact_test.cljc +518 -0
- package/test/datahike/test/tuples_test.cljc +564 -0
- package/test/datahike/test/unstructured_test.cljc +291 -0
- package/test/datahike/test/upsert_impl_test.cljc +205 -0
- package/test/datahike/test/upsert_test.cljc +363 -0
- package/test/datahike/test/utils.cljc +110 -0
- package/test/datahike/test/validation_test.cljc +48 -0
- package/test/datahike/test/versioning_test.cljc +56 -0
- package/test/datahike/test.cljc +66 -0
- package/tests.edn +24 -0
package/doc/config.md
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
# Datahike Database Configuration
|
|
2
|
+
|
|
3
|
+
Datahike is highly configurable to support different deployment models and use cases. Configuration is set at database creation and cannot be changed afterward (though data can be migrated to a new configuration).
|
|
4
|
+
|
|
5
|
+
## Configuration Methods
|
|
6
|
+
|
|
7
|
+
Datahike uses the [environ library](https://github.com/weavejester/environ) for configuration, supporting three methods:
|
|
8
|
+
|
|
9
|
+
1. **Environment variables** (lowest priority)
|
|
10
|
+
2. **Java system properties** (middle priority)
|
|
11
|
+
3. **Configuration map argument** (highest priority - overwrites others)
|
|
12
|
+
|
|
13
|
+
This allows flexible deployment: hardcode configs in development, use environment variables in containers, or Java properties in production JVMs.
|
|
14
|
+
|
|
15
|
+
## Basic Configuration
|
|
16
|
+
|
|
17
|
+
The minimal configuration map includes:
|
|
18
|
+
|
|
19
|
+
```clojure
|
|
20
|
+
{:store {:backend :memory ;keyword - storage backend
|
|
21
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440020"} ;UUID - database identifier
|
|
22
|
+
:name nil ;string - optional database name (auto-generated if nil)
|
|
23
|
+
:schema-flexibility :write ;keyword - :read or :write
|
|
24
|
+
:keep-history? true ;boolean - enable time-travel queries
|
|
25
|
+
:attribute-refs? false ;boolean - use entity IDs for attributes (Datomic-compatible)
|
|
26
|
+
:index :datahike.index/persistent-set ;keyword - index implementation
|
|
27
|
+
:store-cache-size 1000 ;number - store cache entries
|
|
28
|
+
:search-cache-size 10000} ;number - search cache entries
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Quick start** with defaults (in-memory database):
|
|
32
|
+
|
|
33
|
+
```clojure
|
|
34
|
+
(require '[datahike.api :as d])
|
|
35
|
+
(d/create-database) ;; Creates memory DB with sensible defaults
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Storage Backends
|
|
39
|
+
|
|
40
|
+
Datahike supports multiple storage backends via [konserve](https://github.com/replikativ/konserve). The choice of backend determines durability, scalability, and deployment model.
|
|
41
|
+
|
|
42
|
+
**Built-in backends:**
|
|
43
|
+
- `:memory` - In-memory (ephemeral)
|
|
44
|
+
- `:file` - File-based persistent storage
|
|
45
|
+
|
|
46
|
+
**External backend libraries:**
|
|
47
|
+
- [LMDB](https://github.com/replikativ/datahike-lmdb) - High-performance local storage
|
|
48
|
+
- [JDBC](https://github.com/replikativ/datahike-jdbc) - PostgreSQL, MySQL, H2
|
|
49
|
+
- [Redis](https://github.com/replikativ/konserve-redis) - High write throughput
|
|
50
|
+
- [S3](https://github.com/replikativ/konserve-s3) - AWS cloud storage
|
|
51
|
+
- [GCS](https://github.com/replikativ/konserve-gcs) - Google Cloud storage
|
|
52
|
+
- [DynamoDB](https://github.com/replikativ/konserve-dynamodb) - AWS NoSQL
|
|
53
|
+
- [IndexedDB](https://github.com/replikativ/konserve-indexeddb) - Browser storage
|
|
54
|
+
|
|
55
|
+
**For detailed backend selection guidance**, see [Storage Backends Documentation](./storage-backends.md).
|
|
56
|
+
|
|
57
|
+
### Environment Variable Configuration
|
|
58
|
+
|
|
59
|
+
When using environment variables or Java system properties, name them like:
|
|
60
|
+
|
|
61
|
+
properties | envvar
|
|
62
|
+
----------------------------|--------------------------
|
|
63
|
+
datahike.store.backend | DATAHIKE_STORE_BACKEND
|
|
64
|
+
datahike.store.username | DATAHIKE_STORE_USERNAME
|
|
65
|
+
datahike.schema.flexibility | DATAHIKE_SCHEMA_FLEXIBILITY
|
|
66
|
+
datahike.keep.history | DATAHIKE_KEEP_HISTORY
|
|
67
|
+
datahike.attribute.refs | DATAHIKE_ATTRIBUTE_REFS
|
|
68
|
+
datahike.name | DATAHIKE_NAME
|
|
69
|
+
etc.
|
|
70
|
+
|
|
71
|
+
**Note**: Do not use `:` in keyword strings for environment variables—it will be added automatically.
|
|
72
|
+
|
|
73
|
+
### Backend Configuration Examples
|
|
74
|
+
|
|
75
|
+
#### Memory (Built-in)
|
|
76
|
+
|
|
77
|
+
Ephemeral storage for testing and development:
|
|
78
|
+
|
|
79
|
+
```clojure
|
|
80
|
+
{:store {:backend :memory
|
|
81
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440021"}}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Environment variables:
|
|
85
|
+
```bash
|
|
86
|
+
DATAHIKE_STORE_BACKEND=memory
|
|
87
|
+
DATAHIKE_STORE_CONFIG='{:id #uuid "550e8400-e29b-41d4-a716-446655440021"}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### File (Built-in)
|
|
91
|
+
|
|
92
|
+
Persistent local file storage:
|
|
93
|
+
|
|
94
|
+
```clojure
|
|
95
|
+
{:store {:backend :file
|
|
96
|
+
:path "/var/db/datahike"}}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Environment variables:
|
|
100
|
+
```bash
|
|
101
|
+
DATAHIKE_STORE_BACKEND=file
|
|
102
|
+
DATAHIKE_STORE_CONFIG='{:path "/var/db/datahike"}'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### LMDB (External Library)
|
|
106
|
+
|
|
107
|
+
High-performance local storage via [datahike-lmdb](https://github.com/replikativ/datahike-lmdb):
|
|
108
|
+
|
|
109
|
+
```clojure
|
|
110
|
+
{:store {:backend :lmdb
|
|
111
|
+
:path "/var/db/datahike-lmdb"}}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### JDBC (External Library)
|
|
115
|
+
|
|
116
|
+
PostgreSQL or other JDBC databases via [datahike-jdbc](https://github.com/replikativ/datahike-jdbc):
|
|
117
|
+
|
|
118
|
+
```clojure
|
|
119
|
+
{:store {:backend :jdbc
|
|
120
|
+
:dbtype "postgresql"
|
|
121
|
+
:host "db.example.com"
|
|
122
|
+
:port 5432
|
|
123
|
+
:dbname "datahike"
|
|
124
|
+
:user "datahike"
|
|
125
|
+
:password "secret"}}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### S3 (External Library)
|
|
129
|
+
|
|
130
|
+
AWS S3 storage via [konserve-s3](https://github.com/replikativ/konserve-s3):
|
|
131
|
+
|
|
132
|
+
```clojure
|
|
133
|
+
{:store {:backend :s3
|
|
134
|
+
:bucket "my-datahike-bucket"
|
|
135
|
+
:region "us-east-1"}}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### TieredStore (Composable)
|
|
139
|
+
|
|
140
|
+
Memory hierarchy (e.g., Memory → IndexedDB for browsers):
|
|
141
|
+
|
|
142
|
+
```clojure
|
|
143
|
+
{:store {:backend :tiered
|
|
144
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440022"
|
|
145
|
+
:frontend-config {:backend :memory
|
|
146
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440022"}
|
|
147
|
+
:backend-config {:backend :indexeddb
|
|
148
|
+
:name "persistent-db"
|
|
149
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440022"}}}
|
|
150
|
+
;; All :id values must match for konserve validation
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For complete backend options and selection guidance, see [Storage Backends](./storage-backends.md).
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
## Core Configuration Options
|
|
157
|
+
|
|
158
|
+
### Database Name
|
|
159
|
+
|
|
160
|
+
Optional identifier for the database. Auto-generated if not specified. Useful when running multiple databases:
|
|
161
|
+
|
|
162
|
+
```clojure
|
|
163
|
+
{:name "production-db"
|
|
164
|
+
:store {:backend :file :path "/var/db/prod"}}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Schema Flexibility
|
|
168
|
+
|
|
169
|
+
Controls when schema validation occurs:
|
|
170
|
+
|
|
171
|
+
- **`:write`** (default): Strict schema—attributes must be defined before use. Catches errors early.
|
|
172
|
+
- **`:read`**: Schema-less—accept any data, validate on read. Flexible for evolving data models.
|
|
173
|
+
|
|
174
|
+
```clojure
|
|
175
|
+
{:schema-flexibility :read} ;; Allow any data structure
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
With `:read` flexibility, you can still define critical schema like `:db/unique`, `:db/cardinality`, or `:db.type/ref` where needed.
|
|
179
|
+
|
|
180
|
+
See [Schema Documentation](./schema.md) for details.
|
|
181
|
+
|
|
182
|
+
### Time-Travel Queries
|
|
183
|
+
|
|
184
|
+
Enable historical query capabilities:
|
|
185
|
+
|
|
186
|
+
```clojure
|
|
187
|
+
{:keep-history? true} ;; Default: true
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
When enabled, use `history`, `as-of`, and `since` to query past states:
|
|
191
|
+
|
|
192
|
+
```clojure
|
|
193
|
+
(d/q '[:find ?e :where [?e :name "Alice"]] (d/as-of db #inst "2024-01-01"))
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Disable if**: You never need historical queries and want to save storage space.
|
|
197
|
+
|
|
198
|
+
See [Time Variance Documentation](./time_variance.md) for time-travel query examples.
|
|
199
|
+
|
|
200
|
+
### Attribute References
|
|
201
|
+
|
|
202
|
+
Store attributes as entity IDs (integers) instead of keywords in datoms for performance and Datomic compatibility:
|
|
203
|
+
|
|
204
|
+
```clojure
|
|
205
|
+
{:attribute-refs? true} ;; Default: false
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**How it works:**
|
|
209
|
+
|
|
210
|
+
Without attribute references (default):
|
|
211
|
+
```clojure
|
|
212
|
+
;; Datoms store attribute keywords directly
|
|
213
|
+
#datahike/Datom [1 :name "Alice" 536870913 true]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
With attribute references enabled:
|
|
217
|
+
```clojure
|
|
218
|
+
;; Datoms store attribute entity IDs (integers)
|
|
219
|
+
#datahike/Datom [1 73 "Alice" 536870913 true] ;; where 73 is the entity ID for :name
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Benefits:**
|
|
223
|
+
- **Better performance**: Integer comparisons are significantly faster than keyword comparisons, especially with many attributes
|
|
224
|
+
- **Datomic compatibility**: Matches Datomic's internal representation for easier migration
|
|
225
|
+
- **Attributes as entities**: Attributes become queryable entities in the database
|
|
226
|
+
- **Recommended for production**: Generally beneficial unless you have specific reasons to use keywords
|
|
227
|
+
|
|
228
|
+
**Considerations:**
|
|
229
|
+
- Must use `:schema-flexibility :write` (cannot use with `:read`)
|
|
230
|
+
- Requires ID ↔ keyword mapping (maintained automatically)
|
|
231
|
+
- System schema is bootstrapped into the index on database creation
|
|
232
|
+
- You still use keyword syntax in queries and transactions - translation is automatic
|
|
233
|
+
|
|
234
|
+
**Example:**
|
|
235
|
+
|
|
236
|
+
```clojure
|
|
237
|
+
;; Create database with attribute references
|
|
238
|
+
(def cfg {:store {:backend :memory
|
|
239
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440000"}
|
|
240
|
+
:attribute-refs? true
|
|
241
|
+
:schema-flexibility :write})
|
|
242
|
+
|
|
243
|
+
(d/create-database cfg)
|
|
244
|
+
(def conn (d/connect cfg))
|
|
245
|
+
|
|
246
|
+
;; Use normal keyword syntax in transactions and queries
|
|
247
|
+
(d/transact conn [{:db/ident :name
|
|
248
|
+
:db/valueType :db.type/string
|
|
249
|
+
:db/cardinality :db.cardinality/one}])
|
|
250
|
+
|
|
251
|
+
(d/transact conn [{:name "Alice"}])
|
|
252
|
+
|
|
253
|
+
;; Queries use keywords as usual - translation happens automatically
|
|
254
|
+
(d/q '[:find ?n :where [?e :name ?n]] @conn)
|
|
255
|
+
;; => #{["Alice"]}
|
|
256
|
+
|
|
257
|
+
;; But internally, datoms store integer attribute IDs for performance
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**When to use:**
|
|
261
|
+
- **Use `:attribute-refs? true`** for production databases (recommended for performance)
|
|
262
|
+
- Use `:attribute-refs? false` only if you need `:schema-flexibility :read` or have specific compatibility requirements
|
|
263
|
+
|
|
264
|
+
### Index Selection
|
|
265
|
+
|
|
266
|
+
Choose the underlying index implementation:
|
|
267
|
+
|
|
268
|
+
```clojure
|
|
269
|
+
{:index :datahike.index/persistent-set} ;; Default (recommended)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Available indexes**:
|
|
273
|
+
- `:datahike.index/persistent-set` - Default, actively maintained, supports all features
|
|
274
|
+
- `:datahike.index/hitchhiker-tree` - Legacy, requires explicit library and namespace loading
|
|
275
|
+
|
|
276
|
+
Most users should use the default. Hitchhiker-tree is maintained for backward compatibility with existing databases.
|
|
277
|
+
|
|
278
|
+
## Advanced Configuration
|
|
279
|
+
|
|
280
|
+
### Single-Writer Model (Distributed Access)
|
|
281
|
+
|
|
282
|
+
For distributed deployments, configure a writer to handle all transactions while readers access storage directly via Distributed Index Space.
|
|
283
|
+
|
|
284
|
+
#### HTTP Server Writer
|
|
285
|
+
|
|
286
|
+
```clojure
|
|
287
|
+
{:store {:backend :file :path "/shared/db"}
|
|
288
|
+
:writer {:backend :datahike-server
|
|
289
|
+
:url "http://writer.example.com:4444"
|
|
290
|
+
:token "secure-token"}}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Clients connect and transact through the HTTP server. Reads happen locally from shared storage.
|
|
294
|
+
|
|
295
|
+
#### Kabel WebSocket Writer (Beta)
|
|
296
|
+
|
|
297
|
+
Real-time reactive updates via WebSocket:
|
|
298
|
+
|
|
299
|
+
```clojure
|
|
300
|
+
{:store {:backend :indexeddb :name "app-db" :id store-id}
|
|
301
|
+
:writer {:backend :kabel
|
|
302
|
+
:peer-id server-peer-id
|
|
303
|
+
:local-peer @client-peer}} ;; Set up via kabel/distributed-scope
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Enables browser clients with live synchronization. See [Distributed Architecture](./distributed.md) for setup details.
|
|
307
|
+
|
|
308
|
+
### Branching (Beta)
|
|
309
|
+
|
|
310
|
+
Access specific database branches (git-like versioning):
|
|
311
|
+
|
|
312
|
+
```clojure
|
|
313
|
+
{:store {:backend :file :path "/var/db"}
|
|
314
|
+
:branch :staging} ;; Default branch is :db
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Create and merge branches for testing, staging, or experiments. See [Versioning](./versioning.md) for the branching API.
|
|
318
|
+
|
|
319
|
+
### Remote Procedure Calls
|
|
320
|
+
|
|
321
|
+
Send all operations (reads and writes) to a remote server:
|
|
322
|
+
|
|
323
|
+
```clojure
|
|
324
|
+
{:store {:backend :memory :id #uuid "550e8400-e29b-41d4-a716-446655440023"}
|
|
325
|
+
:remote-peer {:backend :datahike-server
|
|
326
|
+
:url "http://server.example.com:4444"
|
|
327
|
+
:token "secure-token"}}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Useful for thin clients or when you want centralized query execution. See [Distributed Architecture](./distributed.md) for RPC vs. DIS trade-offs.
|
|
331
|
+
|
|
332
|
+
### Initial Transaction
|
|
333
|
+
|
|
334
|
+
Seed the database with schema or data on creation:
|
|
335
|
+
|
|
336
|
+
```clojure
|
|
337
|
+
{:store {:backend :memory :id #uuid "550e8400-e29b-41d4-a716-446655440024"}
|
|
338
|
+
:initial-tx [{:db/ident :name
|
|
339
|
+
:db/valueType :db.type/string
|
|
340
|
+
:db/cardinality :db.cardinality/one}
|
|
341
|
+
{:db/ident :email
|
|
342
|
+
:db/valueType :db.type/string
|
|
343
|
+
:db/unique :db.unique/identity
|
|
344
|
+
:db/cardinality :db.cardinality/one}]}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Convenient for testing or deploying databases with predefined schema.
|
|
348
|
+
|
|
349
|
+
### Complete Configuration Example
|
|
350
|
+
|
|
351
|
+
```clojure
|
|
352
|
+
{:store {:backend :file
|
|
353
|
+
:path "/var/datahike/production"
|
|
354
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440000"}
|
|
355
|
+
:name "production-db"
|
|
356
|
+
:schema-flexibility :write
|
|
357
|
+
:keep-history? true
|
|
358
|
+
:attribute-refs? false
|
|
359
|
+
:index :datahike.index/persistent-set
|
|
360
|
+
:store-cache-size 10000
|
|
361
|
+
:search-cache-size 100000
|
|
362
|
+
:initial-tx [{:db/ident :user/email
|
|
363
|
+
:db/valueType :db.type/string
|
|
364
|
+
:db/unique :db.unique/identity
|
|
365
|
+
:db/cardinality :db.cardinality/one}]
|
|
366
|
+
:writer {:backend :datahike-server
|
|
367
|
+
:url "http://writer.example.com:4444"
|
|
368
|
+
:token "secure-token"}
|
|
369
|
+
:branch :db}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Migration and Compatibility
|
|
373
|
+
|
|
374
|
+
### URI Scheme (Pre-0.3.0, Deprecated)
|
|
375
|
+
|
|
376
|
+
Prior to version 0.3.0, Datahike used URI-style configuration. This is **still supported** but deprecated in favor of the more flexible hashmap format.
|
|
377
|
+
|
|
378
|
+
**Old URI format**:
|
|
379
|
+
```clojure
|
|
380
|
+
"datahike:memory://my-db?temporal-index=true&schema-on-read=true"
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**New hashmap format** (equivalent):
|
|
384
|
+
```clojure
|
|
385
|
+
{:store {:backend :memory :id #uuid "550e8400-e29b-41d4-a716-446655440025"}
|
|
386
|
+
:keep-history? true
|
|
387
|
+
:schema-flexibility :read}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Key changes**:
|
|
391
|
+
- `:temporal-index` → `:keep-history?`
|
|
392
|
+
- `:schema-on-read` → `:schema-flexibility` (`:read` or `:write`)
|
|
393
|
+
- Store parameters moved to `:store` map
|
|
394
|
+
- Memory backend: `:host`/`:path` → `:id`
|
|
395
|
+
- Direct support for advanced features (writer, branches, initial-tx)
|
|
396
|
+
|
|
397
|
+
Existing URI configurations continue to work—no migration required unless you need new features.
|
|
398
|
+
|
|
399
|
+
## Further Documentation
|
|
400
|
+
|
|
401
|
+
- [Storage Backends](./storage-backends.md) - Choosing and configuring storage
|
|
402
|
+
- [Schema](./schema.md) - Schema definition and flexibility
|
|
403
|
+
- [Time Variance](./time_variance.md) - Historical queries (as-of, history, since)
|
|
404
|
+
- [Versioning](./versioning.md) - Git-like branching and merging
|
|
405
|
+
- [Distributed Architecture](./distributed.md) - DIS, writers, and RPC
|
|
406
|
+
- [JavaScript API](./javascript-api.md) - Node.js and browser usage
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Contributing to Datahike
|
|
2
|
+
|
|
3
|
+
The current process requires having [babashka](https://github.com/babashka/babashka) installed.
|
|
4
|
+
|
|
5
|
+
An overview of the available tasks will be shown with
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
bb tasks
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Compile Java classes
|
|
13
|
+
```
|
|
14
|
+
bb compile
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Run the tests
|
|
18
|
+
|
|
19
|
+
Unittests
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
# Persistent sorted set index (fast)
|
|
23
|
+
|
|
24
|
+
bb test pss
|
|
25
|
+
#or
|
|
26
|
+
bb test pss --watch
|
|
27
|
+
|
|
28
|
+
# Hitchhiker-tree index (slow)
|
|
29
|
+
|
|
30
|
+
bb test hht
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Integration tests (Docker needed)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
bb test integration
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Backward-compatibility test
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
bb test back-compat
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Native-image test (native-image needed)
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
bb test native-image
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Start the benchmarks
|
|
52
|
+
```
|
|
53
|
+
bb bench
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Build a Datahike jar
|
|
57
|
+
```
|
|
58
|
+
bb jar
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Install Datahike to local maven repository
|
|
62
|
+
```
|
|
63
|
+
bb install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Format
|
|
67
|
+
Check the formatting:
|
|
68
|
+
```
|
|
69
|
+
bb format
|
|
70
|
+
```
|
|
71
|
+
or fix the formatting:
|
|
72
|
+
```
|
|
73
|
+
bb ffix
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Release Datahike
|
|
77
|
+
### Deploying Datahike to Clojars manually
|
|
78
|
+
#### Manually
|
|
79
|
+
**Should only be done in case of emergency**
|
|
80
|
+
First you have to build the artifact with `bb jar`, then you need to
|
|
81
|
+
set `CLOJARS_USERNAME` and `CLOJARS_PASSWORD` as environment variables, then
|
|
82
|
+
you can run `bb deploy` to deploy the artifact to Clojars.
|
|
83
|
+
|
|
84
|
+
#### Pipeline
|
|
85
|
+
[Datahike is released everytime there is a commit to the `main` branch](https://github.com/replikativ/datahike/blob/development/doc/adl/adr-004-github-flow.md).
|
|
86
|
+
We are using semantic versioning and the patch-version is the number of commits on
|
|
87
|
+
the main branch. That means it is always increasing, even if the major or minor
|
|
88
|
+
version is increased.
|
|
89
|
+
|
|
90
|
+
### CircleCI
|
|
91
|
+
Clojars needs to be stored as an environment variable on CircleCI. There needs to be a
|
|
92
|
+
variable `CLOJARS_USERNAME` set to your Clojars username and a variable `CLOJARS_PASSWORD` set
|
|
93
|
+
to the token that permits to deploy on clojars.
|
|
94
|
+
|
|
95
|
+
In order to create new releases on GitHub we need environment variables on CircleCI. The
|
|
96
|
+
two variables `GITHUB_TOKEN` and `GITHUB_USER` need to be set in a context called
|
|
97
|
+
`github-token` in the CircleCI UI for the organisation.
|
|
98
|
+
|
|
99
|
+
### Git tags and GitHub releases
|
|
100
|
+
Each merge to `main` creates a draft release on GitHub and a git tag to point to the merge commit
|
|
101
|
+
made when merging a branch into `main`. The jar is appended to the Github-release.
|
|
102
|
+
|
|
103
|
+
### The release process step by step
|
|
104
|
+
- Set a new version in build.clj if you want to release a new minor or major version.
|
|
105
|
+
For the ordinary patch release you can let the CI automatically increment the patch
|
|
106
|
+
release version.
|
|
107
|
+
- Squash and rebase if you see a need to.
|
|
108
|
+
- Create the PR against the `main` branch.
|
|
109
|
+
- Once approved, merge the PR into `main`.
|
|
110
|
+
+ a new release on Clojars will be created.
|
|
111
|
+
+ a new draft release will be created on GitHub.
|
|
112
|
+
- Go to [GitHub](https://github.com/replikativ/datahike/releases) and
|
|
113
|
+
+ fill in release notes
|
|
114
|
+
+ release the draft Release.
|