mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-03 11:20:16 +01:00
🧑💻 Add internal kernel API /api/attr/batchGetBlockAttrs https://github.com/siyuan-note/siyuan/issues/11786
This commit is contained in:
parent
17dce8ebd2
commit
675ad65bd1
5 changed files with 92 additions and 21 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue