File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
113114from the respective ` history index ` .
114115The root data structure of a xitdb database is a ArrayList, called 'history'.
115116Each 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+
125138It is also possible to create a transaction which returns the previous and current
126139values of the database, by setting the ` *return-history?* ` binding to ` true ` .
127140
You can’t perform that action at this time.
0 commit comments