Skip to content

Commit 479cb0e

Browse files
committed
add deref-at
1 parent 0bea377 commit 479cb0e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/xitdb/db.clj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@
122122
[xdb]
123123
(.count (read-history (-> xdb .tldbro .get))))
124124

125+
(defn deref-at
126+
"Returns the version of the data at the specified index."
127+
[xdb index]
128+
(let [history (read-history (-> xdb .tldbro .get))
129+
cursor (.getCursor history index)]
130+
(xtypes/read-from-cursor cursor false)))
131+
125132
(deftype XITDBDatabase [tldbro rwdb lock]
126133

127134
java.io.Closeable
@@ -131,9 +138,7 @@
131138

132139
clojure.lang.IDeref
133140
(deref [this]
134-
(let [history (read-history (.get tldbro))
135-
cursor (.getCursor history -1)]
136-
(xtypes/read-from-cursor cursor false)))
141+
(deref-at this -1))
137142

138143
clojure.lang.IAtom
139144

0 commit comments

Comments
 (0)