1
+ > ** ⚠️ Alpha Software - Work in Progress**
2
+ >
3
+ > This project is in early development and rapidly evolving.
4
+ > Expect breaking changes, rough edges, and incomplete documentation.
5
+ >
6
+ > ** 🤝 Help Wanted!** If you find this useful, please consider contributing:
7
+ > - Report bugs and issues you encounter
8
+ > - Suggest improvements or new features
9
+ > - Submit pull requests for fixes or enhancements
10
+ > - Share your configuration patterns and workflows
11
+ > - Help improve documentation and examples
12
+ >
13
+ > Your feedback and contributions will help make this tool better for the entire Clojure community!
14
+
1
15
## Overview
2
16
3
17
` xitdb-clj ` is a database for efficiently storing and retrieving immutable, persistent data structures.
@@ -7,10 +21,6 @@ itself a port of [xitdb](https://github.com/radarroark/xitdb), written in Zig.
7
21
8
22
` xitdb-clj ` provides atom-like semantics when working with the database from Clojure.
9
23
10
- ### Experimental
11
-
12
- Code is still in early stages of 'alpha', things might change or break in future versions.
13
-
14
24
## Main characteristics
15
25
16
26
- Embeddable, tiny library.
@@ -61,6 +71,27 @@ For the programmer, a `xitdb` database behaves exactly like a Clojure atom.
61
71
(get-in @db [:users " alice" :age ])
62
72
; ; => 31
63
73
```
74
+ One important distinction to the Clojure atom is that inside a transaction (eg. a ` swap! ` ),
75
+ 'change' operations on the received db argument are mutating it.
76
+
77
+ ``` clojure
78
+ (with-db [db (xdb/xit-db :memory )]
79
+ (reset! db {})
80
+ (swap! db (fn [db]
81
+ (let [db1 (assoc db :foo :bar )]
82
+ (println " db1:" db1)
83
+ (println " db:" db)))))
84
+ ```
85
+ prints
86
+ ```
87
+ db1: {:foo :bar}
88
+ db: {:foo :bar}
89
+ ```
90
+ As you can see, ` (assoc db :foo :bar) ` changed the value of ` db ` , in contrast
91
+ to how it works with a Clojure persistent map. This is because, inside ` swap! ` ,
92
+ ` db ` is referencing a WriteCursor, which writes the value to the underlying
93
+ ArrayList or HashMap objects inside ` xit-db-java ` .
94
+ The value will actually be commited to the database when the ` swap! ` function returns.
64
95
65
96
## Data structures are read lazily from the database
66
97
0 commit comments