From 5d295f2eb8160ef0533bf4d386448b51fe40e9bb Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 28 Jun 2023 13:26:00 +0800 Subject: [PATCH] fix: all blocks in sqlite should have UUID --- src/main/frontend/db/debug.cljs | 10 +++++++++- src/main/frontend/modules/outliner/pipeline.cljs | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/frontend/db/debug.cljs b/src/main/frontend/db/debug.cljs index 5772e6988e..0473029cd3 100644 --- a/src/main/frontend/db/debug.cljs +++ b/src/main/frontend/db/debug.cljs @@ -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))) diff --git a/src/main/frontend/modules/outliner/pipeline.cljs b/src/main/frontend/modules/outliner/pipeline.cljs index af2b72d8b8..ec3830b388 100644 --- a/src/main/frontend/modules/outliner/pipeline.cljs +++ b/src/main/frontend/modules/outliner/pipeline.cljs @@ -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