Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.

Remove unused title field

kageru 4 years ago
parent 99d20cf1f6
commit 645756d800
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2


@ -20,12 +20,12 @@ func initializeDatabase() {
func writeToDB(post BlogPost) {
stmt, _ := db.Prepare("INSERT INTO blogposts(author, title, content, time) VALUES (?, ?, ?, ?)")
stmt.Exec(post.Author, post.Title, post.Content, time.Now().Unix())
stmt, _ := db.Prepare("INSERT INTO blogposts(author, content, time) VALUES (?, ?, ?)")
stmt.Exec(post.Author, post.Content, time.Now().Unix())
func readBlogpostsFromDB() []BlogPost {
res, err := db.Query("SELECT content, author, title, time from blogposts")
res, err := db.Query("SELECT content, title, time from blogposts limit 50")
if err != nil {
log.Println("Error reading blogposts")
return make([]BlogPost, 0)
@ -38,10 +38,10 @@ func resultToBlogposts(res *sql.Rows) []BlogPost {
defer res.Close()
entries := make([]BlogPost, 0)
for res.Next() {
var content, author, title string
var content, author string
var timeInt int64
res.Scan(&content, &author, &title, &timeInt)
post := BlogPost{Content:content, Author:author, Title:title, FTime:time.Unix(timeInt, 0).Format("02.01.2006 - 15:04:05")}
res.Scan(&content, &author, &timeInt)
post := BlogPost{Content:content, Author:author, FTime:time.Unix(timeInt, 0).Format("02.01.2006 - 15:04:05")}
entries = append(entries, post)
return entries

@ -16,7 +16,6 @@ func main() {
type BlogPost struct {
Id int64 `"id"`
Content string `"content"`
Title string `"title"`
Author string `"author"`
Secret string `"secret"`
Time time.Time `"time"`

@ -1 +1 @@
CREATE TABLE `blogposts` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `author` VARCHAR(32) NULL, `title` text NULL, `content` text null, `time` time null);
CREATE TABLE `blogposts` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `author` VARCHAR(32) NULL, `content` text null, `time` time null);

@ -5,5 +5,5 @@ else
curl localhost:12345/add -d "{\"content\": \"$msg\", \"Title\": \"title\", \"Secret\": \"asdf\", \"author\": \"kageru\"}" -H "Content-Type: application/json" -v
curl localhost:12345/add -d "{\"content\": \"$msg\", \"Secret\": \"asdf\", \"author\": \"kageru\"}" -H "Content-Type: application/json" -v