fix: all blocks in sqlite should have UUID

This commit is contained in:
Tienson Qin
2023-06-28 13:26:00 +08:00
parent 6872ed545c
commit 5d295f2eb8
2 changed files with 10 additions and 5 deletions

View File

@@ -2,7 +2,8 @@
(:require [frontend.db.utils :as db-utils]
[frontend.db :as db]
[datascript.core :as d]
[frontend.util :as util]))
[frontend.util :as util]
[frontend.state :as state]))
;; shortcut for query a block with string ref
(defn qb
@@ -45,3 +46,10 @@
(vector? x)
(= :block/uuid (first x))
(nil? (second x)))))))
(defn get-all-blocks
[]
(when-let [db (db/get-db)]
(->> (d/datoms db :avet :block/uuid)
(map :e)
db/pull-many)))

View File

@@ -155,10 +155,7 @@
(assoc b :page_uuid page-uuid)
b)))
(map (fn [b]
(let [uuid (or (:block/uuid b)
(:db/ident b)
(:file/path b)
(random-uuid))]
(let [uuid (or (:block/uuid b) (random-uuid))]
(assoc b :block/uuid uuid)))))]
(p/let [ipc-result (ipc/ipc :db-transact-data repo
(pr-str