diff options
author | Vikas Kushwaha <dev@vikas.rocks> | 2025-02-11 16:31:08 +0530 |
---|---|---|
committer | Vikas Kushwaha <dev@vikas.rocks> | 2025-02-11 16:31:08 +0530 |
commit | 57eb8f6712361a3bf75983ce153fac4846dc0273 (patch) | |
tree | 269a168d59c917c4e313c819e2b4c3ff8175f912 /cmd/web/model/comment.go |
Initial commit
Diffstat (limited to 'cmd/web/model/comment.go')
-rw-r--r-- | cmd/web/model/comment.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd/web/model/comment.go b/cmd/web/model/comment.go new file mode 100644 index 0000000..c979edc --- /dev/null +++ b/cmd/web/model/comment.go @@ -0,0 +1,17 @@ +package model + +import "gorm.io/gorm" + +type Comment struct { + gorm.Model + Article Article `validate:"-"` + ArticleID uint + User User `validate:"-"` + UserID uint + Body string `validate:"required"` +} + +func (Comment Comment) GetFormattedCreatedAt() string { + dateLayout := "Jan 02, 2006" + return Comment.CreatedAt.Format(dateLayout) +} |