Skip to content

Commit 3a41bbc

Browse files
committed
fix: exclude duplicated datoms from tail when restore db
1 parent 1f84d10 commit 3a41bbc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/datascript/storage.cljs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@
158158
:max-eid max-eid
159159
:max-tx max-tx})]
160160
(remember-db db)
161-
[db (mapv #(mapv (fn [[e a v tx]] (db/datom e a v tx)) %) tail)]))))
161+
[db (mapv #(keep (fn [[e a v tx]]
162+
(when (nil? (db/-datoms db :eavt e a v nil))
163+
(db/datom e a v tx))) %)
164+
tail)]))))
162165

163166
(defn db-with-tail [db tail]
164167
(reduce

0 commit comments

Comments
 (0)