aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2017-06-18 05:53:42 +0000
committerFelix Hanley <felix@userspace.com.au>2017-06-18 05:53:42 +0000
commit30fc93f11537789824eeb24bde212a57e43ecb01 (patch)
treee83e685519c704adb97e34ea1bdef9ab6b8d484f /db.go
parent3e3fa4064fcaf43cd87ddbfc457097bacb697fc5 (diff)
downloaddhtsearch-30fc93f11537789824eeb24bde212a57e43ecb01.tar.gz
dhtsearch-30fc93f11537789824eeb24bde212a57e43ecb01.tar.bz2
Add user configuration and more exported variables
Diffstat (limited to 'db.go')
-rw-r--r--db.go26
1 files changed, 1 insertions, 25 deletions
diff --git a/db.go b/db.go
index 9e513dd..a3c46f7 100644
--- a/db.go
+++ b/db.go
@@ -8,7 +8,6 @@ import (
type database struct {
*sqlx.DB
- debug bool
}
func newDB(dsn string) (*database, error) {
@@ -23,28 +22,5 @@ func newDB(dsn string) (*database, error) {
return nil, err
}
torrentsTotal.Set(int64(count))
- return &database{d, false}, nil
-}
-
-func createTag(tag string) (tagId int, err error) {
- if DB.debug {
- fmt.Printf("Writing tag %s\n", tag)
- }
-
- err = DB.QueryRow("select id from tags where name = $1", tag).Scan(&tagId)
- if err == nil {
- if DB.debug {
- fmt.Printf("Found existing tag %s\n", tag)
- }
- } else {
- err = DB.QueryRow("insert into tags (name) values ($1) returning id", tag).Scan(&tagId)
- if err != nil {
- fmt.Println(err)
- return -1, err
- }
- if DB.debug {
- fmt.Printf("Created new tag %s\n", tag)
- }
- }
- return tagId, nil
+ return &database{d}, nil
}