mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
add session api to use read replica
This commit is contained in:
19
deps/db-sync/src/logseq/db_sync/common.cljs
vendored
19
deps/db-sync/src/logseq/db_sync/common.cljs
vendored
@@ -67,12 +67,19 @@
|
||||
(.run stmt)))
|
||||
|
||||
(defn <d1-all
|
||||
[^js db sql-str & args]
|
||||
(p/let [^js stmt (.prepare db sql-str)
|
||||
^js stmt (if (seq args)
|
||||
(.apply (.-bind stmt) stmt (to-array args))
|
||||
stmt)]
|
||||
(.all stmt)))
|
||||
[^js db sql-or-opts & more]
|
||||
(let [[opts sql-str args] (if (map? sql-or-opts)
|
||||
[sql-or-opts (first more) (rest more)]
|
||||
[nil sql-or-opts more])
|
||||
session-mode (:session opts)
|
||||
session (if (some? session-mode)
|
||||
(.withSession db session-mode)
|
||||
(.withSession db))]
|
||||
(p/let [^js stmt (.prepare session sql-str)
|
||||
^js stmt (if (seq args)
|
||||
(.apply (.-bind stmt) stmt (to-array args))
|
||||
stmt)]
|
||||
(.all stmt))))
|
||||
|
||||
(defn read-json [request]
|
||||
(p/let [body (.text request)]
|
||||
|
||||
8
deps/db-sync/src/logseq/db_sync/index.cljs
vendored
8
deps/db-sync/src/logseq/db_sync/index.cljs
vendored
@@ -129,7 +129,7 @@
|
||||
|
||||
(defn <user-id-by-email [db email]
|
||||
(when (string? email)
|
||||
(p/let [result (common/<d1-all db
|
||||
(p/let [result (common/<d1-all db {:session "first-primary"}
|
||||
"select id from users where email = ?"
|
||||
email)
|
||||
rows (common/get-sql-rows result)
|
||||
@@ -157,7 +157,7 @@
|
||||
(defn <user-rsa-key-pair
|
||||
[db user-id]
|
||||
(when (string? user-id)
|
||||
(p/let [result (common/<d1-all db
|
||||
(p/let [result (common/<d1-all db {:session "first-primary"}
|
||||
"select public_key, encrypted_private_key from user_rsa_keys where user_id = ?"
|
||||
user-id)
|
||||
rows (common/get-sql-rows result)
|
||||
@@ -169,7 +169,7 @@
|
||||
(defn <user-rsa-public-key-by-email
|
||||
[db email]
|
||||
(when (string? email)
|
||||
(p/let [result (common/<d1-all db
|
||||
(p/let [result (common/<d1-all db {:session "first-primary"}
|
||||
(str "select k.public_key from user_rsa_keys k "
|
||||
"left join users u on k.user_id = u.id "
|
||||
"where u.email = ?")
|
||||
@@ -222,7 +222,7 @@
|
||||
now)))
|
||||
|
||||
(defn <graph-members-list [db graph-id]
|
||||
(p/let [result (common/<d1-all db
|
||||
(p/let [result (common/<d1-all db {:session "first-primary"}
|
||||
(str "select m.user_id, m.graph_id, m.role, m.invited_by, m.created_at, "
|
||||
"u.email, u.username "
|
||||
"from graph_members m "
|
||||
|
||||
Reference in New Issue
Block a user