diff options
author | Joe Robinson <joe@mumsnet.com> | 2014-07-18 18:27:00 +0100 |
---|---|---|
committer | Joe Robinson <joe@mumsnet.com> | 2014-07-18 18:27:00 +0100 |
commit | 70b4b1dc65bfd493088443c20c4670a62c06f317 (patch) | |
tree | ec44625cc577f197b7c98edc0de8eb4d30bc4b2c /poll.go | |
parent | 0913485975baf0a5db4939ab3112ed7b8883d0f1 (diff) |
Added initial voting functionality
Diffstat (limited to 'poll.go')
-rw-r--r-- | poll.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 +} + |