From db1ac7c3adb2ee8d2a3c7e9ccbcdb742f5850574 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 9 Jul 2017 13:00:26 +1200 Subject: [PATCH] db: add TotalRevisions() implementation --- DB.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/DB.go b/DB.go index 85cbf9e..61a219c 100644 --- a/DB.go +++ b/DB.go @@ -104,6 +104,17 @@ func (this *WikiDB) GetLatestVersion(title string) (*Article, error) { return this.parseArticle(row) } +func (this *WikiDB) TotalRevisions() (int64, error) { + row := this.db.QueryRow(`SELECT COUNT(*) c FROM articles`) + var ret int64 + err := row.Scan(&ret) + if err != nil { + return 0, err + } + + return ret, nil +} + func (this *WikiDB) ListTitles() ([]string, error) { rows, err := this.db.Query(`SELECT title FROM titles ORDER BY title ASC`) if err != nil {