🧑‍💻 Add internal kernel API /api/attr/batchGetBlockAttrs https://github.com/siyuan-note/siyuan/issues/11786

This commit is contained in:
Daniel 2024-06-21 23:07:26 +08:00
parent 17dce8ebd2
commit 675ad65bd1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 92 additions and 21 deletions

View file

@ -23,6 +23,7 @@ import (
"os"
"runtime"
"runtime/debug"
"strings"
"sync"
"time"
@ -303,6 +304,26 @@ func ExistBlockTree(id string) bool {
return 0 < count
}
func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
ret = map[string]*BlockTree{}
sqlStmt := "SELECT * 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 block BlockTree
if err = rows.Scan(&block.ID, &block.RootID, &block.ParentID, &block.BoxID, &block.Path, &block.HPath, &block.Updated, &block.Type); nil != err {
logging.LogErrorf("query scan field failed: %s", err)
return
}
ret[block.ID] = &block
}
return
}
func GetBlockTree(id string) (ret *BlockTree) {
if "" == id {
return