mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 数据历史文档和资源文件支持分页和搜索 https://github.com/siyuan-note/siyuan/issues/4901
This commit is contained in:
parent
23e09027e7
commit
40ade96b89
2 changed files with 65 additions and 0 deletions
|
|
@ -20,6 +20,8 @@ import (
|
|||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
type History struct {
|
||||
|
|
@ -31,6 +33,31 @@ type History struct {
|
|||
Path string
|
||||
}
|
||||
|
||||
func SelectHistoriesRawStmt(stmt string) (ret []*History) {
|
||||
rows, err := historyDB.Query(stmt)
|
||||
if nil != err {
|
||||
logging.LogWarnf("sql query [%s] failed: %s", stmt, err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
if history := scanHistoryRows(rows); nil != history {
|
||||
ret = append(ret, history)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func scanHistoryRows(rows *sql.Rows) (ret *History) {
|
||||
var history History
|
||||
if err := rows.Scan(&history.Type, &history.Op, &history.Title, &history.Content, &history.Created, &history.Path); nil != err {
|
||||
logging.LogErrorf("query scan field failed: %s\n%s", err, logging.ShortStack())
|
||||
return
|
||||
}
|
||||
ret = &history
|
||||
return
|
||||
}
|
||||
|
||||
func DeleteHistoriesByPathPrefix(tx *sql.Tx, pathPrefix string) (err error) {
|
||||
stmt := "DELETE FROM histories_fts_case_insensitive WHERE path LIKE ?"
|
||||
if err = execStmtTx(tx, stmt, pathPrefix+"%"); nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue