comment

package
v0.0.0-...-2aee9c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	gorm.Model
	Slug    string
	Body    string
	Author  string
	Created time.Time
}

Comment

type CommentService

type CommentService interface {
	GetComment(ID uint) (Comment, error)
	PostComment(comment Comment) (Comment, error)
	UpdateComment(ID uint, newComment Comment) (Comment, error)
	DeleteComment(ID uint) error
	GetAllComments() ([]Comment, error)
}

CommentService -

type Service

type Service struct {
	Database *gorm.DB
}

The comment service

func NewService

func NewService(db *gorm.DB) *Service

Returns a new comments service

func (*Service) DeleteComment

func (service *Service) DeleteComment(ID uint) error

Deletes a comment from the database by ID

func (*Service) GetAllComments

func (s *Service) GetAllComments() ([]Comment, error)

Retrieves all comments from the database

func (*Service) GetComment

func (service *Service) GetComment(ID uint) (Comment, error)

Retrieves comments by their ID from the database

func (*Service) GetCommentsBySlug

func (service *Service) GetCommentsBySlug(slug string) ([]Comment, error)

Retrieves all comments by slug (path - /article/name/)

func (*Service) PostComment

func (service *Service) PostComment(comment Comment) (Comment, error)

Adds a new comment to the database

func (*Service) UpdateComment

func (service *Service) UpdateComment(ID uint, newComment Comment) (Comment, error)

Updates a comment by ID with new comment info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL