added a 404 to bad blog posts

This commit is contained in:
rawleyIfowler
2022-02-23 19:24:31 -06:00
parent 4f9fcdc898
commit 8e389c7a7f
5 changed files with 26 additions and 14 deletions

View File

@@ -26,5 +26,5 @@ type BlogPost struct {
Title string `json:"title" gorm:"unique"`
Date string `json:"date"`
Content string `json:"content"`
Comments []Comment `gorm:"foreignKey:Id"`
Comments []Comment `gorm:"foreignKey:AssociatedPost"`
}

View File

@@ -22,8 +22,9 @@ import (
type Comment struct {
gorm.Model
Id uint `json:"id"`
Date string `json:"date"`
Author string `json:"author"`
Content string `json:"content"`
Id uint `json:"id" gorm: "primaryKey" gorm: "unique"`
Date string `json:"date"`
Author string `json:"author" form:"author"`
Content string `json:"content" form:"content"`
AssociatedPost string
}