mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
♻️ 重构 文件历史 查询 https://github.com/siyuan-note/siyuan/issues/6504
This commit is contained in:
parent
b0fe8b49ba
commit
24edac891e
4 changed files with 108 additions and 0 deletions
|
|
@ -69,6 +69,31 @@ func QueryHistory(stmt string) (ret []map[string]interface{}, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
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.Path, &history.Created); nil != err {
|
||||
logging.LogErrorf("query scan field failed: %s\n%s", err, logging.ShortStack())
|
||||
return
|
||||
}
|
||||
ret = &history
|
||||
return
|
||||
}
|
||||
|
||||
func queryHistory(query string, args ...interface{}) (*sql.Rows, error) {
|
||||
query = strings.TrimSpace(query)
|
||||
if "" == query {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue