Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { gorm.Model UserID uint32 `json:"user_id" gorm:"not null"` Title string `json:"title" gorm:"not null"` Content string `json:"content"` }
Article corresponds to articles users can write
type Repository ¶
type Repository interface { CreateArticle(article *Article) (*Article, error) GetUserArticles(userID uint32) (*[]Article, error) GetAllArticles() (*[]Article, error) GetArticlebyID(ID uint32) (*Article, error) DeleteArticle(ID uint32) (bool, error) }
Repository interface for a layer of abstraction over the db functions
func NewDatabaseRepo ¶
func NewDatabaseRepo(db *gorm.DB) Repository
NewDatabaseRepo adds a layer of abstraction so that everything in the interface Repository can be accessed only via the instance of this function
type Service ¶
type Service interface { CreateArticle(article *Article) (*Article, error) GetUserArticles(userID uint32) (*[]Article, error) GetAllArticles() (*[]Article, error) GetArticleByID(ID uint32) (*Article, error) DeleteArticle(ID uint32) (bool, error) }
Service is another abstraction over repository
Click to show internal directories.
Click to hide internal directories.