added comments and added a comment end point
This commit is contained in:
@@ -22,9 +22,9 @@ import (
|
||||
|
||||
type BlogPost struct {
|
||||
gorm.Model
|
||||
Url string `json:"url" gorm:"primaryKey" gorm:"unique"`
|
||||
Url string `json:"url" gorm:"primaryKey"`
|
||||
Title string `json:"title" gorm:"unique"`
|
||||
Date string `json:"date"`
|
||||
Date string `json:"date" gorm:"default:NOW()"`
|
||||
Content string `json:"content"`
|
||||
Comments []Comment `gorm:"foreignKey:AssociatedPost"`
|
||||
Comments []Comment `gorm:"foreignKey:AssociatedPost;references:Url;type:varchar(191)"`
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
|
||||
type Comment struct {
|
||||
gorm.Model
|
||||
Id uint `json:"id" gorm: "primaryKey" gorm: "unique"`
|
||||
Date string `json:"date"`
|
||||
Id uint `json:"id" gorm:"primaryKey, AUTO_INCREMENT"`
|
||||
Date string `json:"date" gorm:"default:NOW()"`
|
||||
Author string `json:"author" form:"author"`
|
||||
Content string `json:"content" form:"content"`
|
||||
AssociatedPost string
|
||||
|
||||
Reference in New Issue
Block a user