From 70b4b1dc65bfd493088443c20c4670a62c06f317 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 18 Jul 2014 18:27:00 +0100 Subject: Added initial voting functionality --- poll.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'poll.go') 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 +} + -- cgit v1.2.3