Skip to content

Commit 171ea9b

Browse files
xeubiecodeboost
authored andcommitted
update readme
1 parent c596249 commit 171ea9b

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ Here's a taste of how your queries could look like:
109109
```
110110

111111
## History
112-
Since the database is immutable, all previous values are accessing by reading
112+
113+
Since the database is immutable, all previous values are accessed by reading
113114
from the respective `history index`.
114115
The root data structure of a xitdb database is a ArrayList, called 'history'.
115116
Each transaction adds a new entry into this array, which points to the latest value
@@ -122,6 +123,18 @@ of the database (usually a map).
122123
(xdb/deref-at db 1) ;; the second value
123124
```
124125

126+
You can get the latest history index from the `count` of the database:
127+
128+
```clojure
129+
(def history-index (dec (count db)))
130+
```
131+
132+
After making further transactions, you can revert back to it simply like this:
133+
134+
```clojure
135+
(reset! db (xdb/deref-at db history-index))
136+
```
137+
125138
It is also possible to create a transaction which returns the previous and current
126139
values of the database, by setting the `*return-history?*` binding to `true`.
127140

0 commit comments

Comments
 (0)