summaryrefslogtreecommitdiff
path: root/poll.go
diff options
context:
space:
mode:
authorJoe Robinson <joe@mumsnet.com>2014-07-18 18:27:00 +0100
committerJoe Robinson <joe@mumsnet.com>2014-07-18 18:27:00 +0100
commit70b4b1dc65bfd493088443c20c4670a62c06f317 (patch)
treeec44625cc577f197b7c98edc0de8eb4d30bc4b2c /poll.go
parent0913485975baf0a5db4939ab3112ed7b8883d0f1 (diff)
Added initial voting functionality
Diffstat (limited to 'poll.go')
-rw-r--r--poll.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/poll.go b/poll.go
index 9cb085e..83d1281 100644
--- a/poll.go
+++ b/poll.go
@@ -8,7 +8,7 @@ type Poll struct {
userId int
}
-func addPoll(db *sqlite3.Conn, title string, options []string, nick string) error {
+func addPoll(db *sqlite3.Conn, title string, options []string, nick string) (int64, error) {
user := getUserForName(db, nick)
@@ -23,18 +23,18 @@ func addPoll(db *sqlite3.Conn, title string, options []string, nick string) erro
err := db.Exec(sql, args)
if (err != nil ) {
- return err
+ return 0, err
}
pollId := db.LastInsertId()
for _,option := range options {
addOption(db, option, pollId)
if (err != nil ) {
- return err
+ return 0, err
}
}
- return nil
+ return pollId, nil
}
@@ -70,4 +70,5 @@ func getPollFromTitle(db *sqlite3.Conn, title string) Poll {
//If we get here there are no matching users
return Poll{id:0, title:"", userId:0}
-} \ No newline at end of file
+}
+