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