mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
⚡ Improve performance for rendering databases, due flashcards
This commit is contained in:
parent
65f24b376e
commit
06f3721fd4
6 changed files with 36 additions and 7 deletions
|
|
@ -304,6 +304,30 @@ func ExistBlockTree(id string) bool {
|
|||
return 0 < count
|
||||
}
|
||||
|
||||
func ExistBlockTrees(ids []string) (ret map[string]bool) {
|
||||
ret = map[string]bool{}
|
||||
for _, id := range ids {
|
||||
ret[id] = false
|
||||
}
|
||||
|
||||
sqlStmt := "SELECT id FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
||||
rows, err := db.Query(sqlStmt)
|
||||
if nil != err {
|
||||
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var id string
|
||||
if err = rows.Scan(&id); nil != err {
|
||||
logging.LogErrorf("query scan field failed: %s", err)
|
||||
return
|
||||
}
|
||||
ret[id] = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
|
||||
ret = map[string]*BlockTree{}
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue