mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 10:56:32 +00:00
feat(search): single database done
This commit is contained in:
@@ -21,12 +21,16 @@
|
||||
:uuid (str uuid)
|
||||
:content result}))
|
||||
|
||||
(defn build-blocks-indice
|
||||
[repo]
|
||||
(->> (db/get-all-block-contents)
|
||||
(map block->index)
|
||||
(remove nil?)
|
||||
(bean/->js)))
|
||||
|
||||
(defn make-blocks-indice!
|
||||
[repo]
|
||||
(let [blocks (->> (db/get-all-block-contents)
|
||||
(map block->index)
|
||||
(remove nil?)
|
||||
(bean/->js))
|
||||
(let [blocks (build-blocks-indice repo)
|
||||
indice (fuse. blocks
|
||||
(clj->js {:keys ["uuid" "content"]
|
||||
:shouldSort true
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
(ns frontend.search.node
|
||||
(:require [frontend.search.protocol :as protocol]
|
||||
[frontend.util :as util]))
|
||||
|
||||
;; sqlite3
|
||||
[frontend.util :as util]
|
||||
[electron.ipc :as ipc]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.search.db :as search-db]
|
||||
[frontend.db :as db]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defrecord Node [repo]
|
||||
protocol/Engine
|
||||
(query [this q option])
|
||||
(rebuild-blocks-indice! [this])
|
||||
(transact-blocks! [this data])
|
||||
(truncate-blocks! [this]))
|
||||
(query [this q {:keys [limit]
|
||||
:or {limit 20}}]
|
||||
(p/let [result (ipc/ipc "search-blocks" repo q limit)
|
||||
result (bean/->clj result)]
|
||||
(map (fn [{:keys [content id uuid]}]
|
||||
{:block/uuid uuid
|
||||
:block/content content
|
||||
:block/page (:block/page (db/entity id))}) result)))
|
||||
(rebuild-blocks-indice! [this]
|
||||
(let [indice (search-db/build-blocks-indice repo)]
|
||||
(ipc/ipc "rebuild-blocks-indice" repo indice)))
|
||||
(transact-blocks! [this data]
|
||||
(ipc/ipc "transact-blocks" repo (bean/->js data)))
|
||||
(truncate-blocks! [this]
|
||||
(ipc/ipc "truncate-blocks" repo)))
|
||||
|
||||
Reference in New Issue
Block a user