mirror of https://github.com/logseq/logseq
parent
2a17e04aa2
commit
12b6ded0e4
|
@ -23,10 +23,7 @@
|
|||
remove-conn!]
|
||||
|
||||
[frontend.db.utils
|
||||
db->edn-str db->string get-max-tx-id get-tx-id
|
||||
group-by-page seq-flatten
|
||||
string->db
|
||||
|
||||
entity pull pull-many transact! get-key-value]
|
||||
|
||||
[frontend.db.model
|
||||
|
|
|
@ -2,22 +2,12 @@
|
|||
"Some utils are required by other namespace in frontend.db package."
|
||||
(:require [datascript.core :as d]
|
||||
[frontend.state :as state]
|
||||
[datascript.transit :as dt]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.config :as config]
|
||||
[logseq.db.frontend.content :as db-content]))
|
||||
|
||||
;; transit serialization
|
||||
|
||||
(defn db->string [db]
|
||||
(dt/write-transit-str db))
|
||||
|
||||
(defn db->edn-str [db]
|
||||
(pr-str db))
|
||||
|
||||
(defn string->db [s]
|
||||
(dt/read-transit-str s))
|
||||
|
||||
(defn seq-flatten [col]
|
||||
(flatten (seq col)))
|
||||
|
||||
|
@ -28,13 +18,6 @@
|
|||
(group-by :block/page))
|
||||
blocks))
|
||||
|
||||
(defn get-tx-id [tx-report]
|
||||
(get-in tx-report [:tempids :db/current-tx]))
|
||||
|
||||
(defn get-max-tx-id
|
||||
[db]
|
||||
(:max-tx db))
|
||||
|
||||
(defn entity
|
||||
"This function will return nil if passed `id-or-lookup-ref` is an integer and
|
||||
the entity doesn't exist in db.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[datascript.storage :refer [IStorage]]
|
||||
[clojure.edn :as edn]
|
||||
[datascript.core :as d]
|
||||
[datascript.transit :as dt]
|
||||
[logseq.db.sqlite.common-db :as sqlite-common-db]
|
||||
[shadow.cljs.modern :refer [defclass]]
|
||||
["@logseq/sqlite-wasm" :default sqlite3InitModule]
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
[frontend.handler.worker :as worker-handler]
|
||||
[logseq.db :as ldb]
|
||||
[frontend.db.transact :as db-transact]
|
||||
[frontend.date :as date]
|
||||
[datascript.transit :as dt]))
|
||||
[frontend.date :as date]))
|
||||
|
||||
(defonce *worker state/*db-worker)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
application"
|
||||
(:require [frontend.state :as state]
|
||||
[datascript.core :as d]
|
||||
[datascript.transit :as dt]
|
||||
[frontend.db :as db]
|
||||
[rum.core :as rum]
|
||||
[frontend.handler.route :as route-handler]
|
||||
|
@ -58,7 +59,7 @@
|
|||
(state/set-current-repo! repo)
|
||||
(p/let [_ (repo-handler/restore-and-setup-repo! repo)
|
||||
_ (let [data (unescape-html data)
|
||||
db (db/string->db data)
|
||||
db (dt/read-transit-str data)
|
||||
datoms (d/datoms db :eavt)]
|
||||
(db/transact! repo datoms {:init-db? true
|
||||
:new-graph? true}))]
|
||||
|
|
Loading…
Reference in New Issue