Fixed wrong column names in select
This commit is contained in:
parent
ff9ae9eb14
commit
b941c4f901
6
db.go
6
db.go
@ -25,9 +25,9 @@ func writeToDB(post BlogPost) {
|
||||
}
|
||||
|
||||
func readBlogpostsFromDB() []BlogPost {
|
||||
res, err := db.Query("SELECT content, title, time from blogposts limit 50")
|
||||
res, err := db.Query("SELECT content, author, time from blogposts limit 50")
|
||||
if err != nil {
|
||||
log.Println("Error reading blogposts")
|
||||
log.Println("Error reading blogposts", err)
|
||||
return make([]BlogPost, 0)
|
||||
} else {
|
||||
return resultToBlogposts(res)
|
||||
@ -41,7 +41,7 @@ func resultToBlogposts(res *sql.Rows) []BlogPost {
|
||||
var content, author string
|
||||
var timeInt int64
|
||||
res.Scan(&content, &author, &timeInt)
|
||||
post := BlogPost{Content:content, Author:author, FTime:time.Unix(timeInt, 0).Format("02.01.2006 - 15:04:05")}
|
||||
post := BlogPost{Content:content, Author:author, FTime:time.Unix(timeInt, 0).Format("02.01. 15:04:05")}
|
||||
entries = append(entries, post)
|
||||
}
|
||||
return entries
|
||||
|
Loading…
Reference in New Issue
Block a user