Skip to content

Commit

Permalink
Return nil from restore-conn if no database
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Aug 14, 2023
1 parent 7528577 commit 6c18d23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/datascript/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,13 @@

#?(:clj
(defn restore-conn
"Lazy-load database from storage and make conn out of it"
"Lazy-load database from storage and make conn out of it.
Returns nil if there’s no database yet in storage"
([storage]
(restore-conn storage {}))
([storage opts]
(let [[db tail] (storage/restore-impl storage opts)
db' (storage/db-with-tail db tail)]
(atom db'
(when-some [[db tail] (storage/restore-impl storage opts)]
(atom (storage/db-with-tail db tail)
:meta {:listeners (atom {})
:tx-tail (atom tail)
:db-last-stored (atom db)})))))
Expand Down

0 comments on commit 6c18d23

Please sign in to comment.