Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-11-24 10:30:06 +08:00
parent bcef9bdff9
commit 8429a1df0b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 67 additions and 2 deletions

View file

@ -410,6 +410,18 @@ func RemoveBlockTreesByRootID(rootID string) {
}
}
func CountBlockTreesByPathPrefix(pathPrefix string) (ret int) {
sqlStmt := "SELECT COUNT(*) FROM blocktrees WHERE path LIKE ?"
err := db.QueryRow(sqlStmt, pathPrefix+"%").Scan(&ret)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return 0
}
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
}
return
}
func GetBlockTreesByPathPrefix(pathPrefix string) (ret []*BlockTree) {
sqlStmt := "SELECT * FROM blocktrees WHERE path LIKE ?"
rows, err := db.Query(sqlStmt, pathPrefix+"%")