Documentation ¶
Index ¶
- type Article
- type ArticlesData
- type ArticlesDb
- func (db *ArticlesDb) AddArticle(ar Article) error
- func (db *ArticlesDb) Close()
- func (db *ArticlesDb) GetArticleByID(id int) (*Article, error)
- func (db *ArticlesDb) GetArticlesForTagAndDate(tag string, d string) ([]int, error)
- func (db *ArticlesDb) GetRelatedTagsForTag(tag string, articles []int) ([]string, error)
- type Tag
- type Validation
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { // Unique identifier for the article // // min: 1 ID int `json:"id"` // the title for this article // // required: true // max length: 500 Title string `json:"title" validate:"required"` // the date of the article // // required: true Date string `json:"date"` // the body for this article // // required: true // max length: 10000 Body string `json:"body" validate:"required"` // the tags for the article // // required: false Tags []string `json:"tags"` }
type ArticlesData ¶
type ArticlesDb ¶
type ArticlesDb struct {
// contains filtered or unexported fields
}
func NewDB ¶
func NewDB(l *zap.Logger) *ArticlesDb
func (*ArticlesDb) AddArticle ¶
func (db *ArticlesDb) AddArticle(ar Article) error
AddProduct adds a new product to the database
func (*ArticlesDb) Close ¶
func (db *ArticlesDb) Close()
func (*ArticlesDb) GetArticleByID ¶
func (db *ArticlesDb) GetArticleByID(id int) (*Article, error)
func (*ArticlesDb) GetArticlesForTagAndDate ¶
func (db *ArticlesDb) GetArticlesForTagAndDate(tag string, d string) ([]int, error)
func (*ArticlesDb) GetRelatedTagsForTag ¶
func (db *ArticlesDb) GetRelatedTagsForTag(tag string, articles []int) ([]string, error)
type Tag ¶
type Tag struct { // Tag name Tag string `json:"tag"` // Number of articles having the tag for that day. Count int `json:"count"` // List of ids for the last 10 articles entered for that day. Articles []int `json:"articles"` // List of tags that are on the articles that the current tag is on for the same day. RelatedTags []string `json:"related_tags"` }
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
Validation contains
func (*Validation) Validate ¶
func (v *Validation) Validate(i interface{}) ValidationErrors
type ValidationError ¶
type ValidationError struct {
validator.FieldError
}
ValidationError wraps the validators FieldError
func (ValidationError) Error ¶
func (v ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a collection of ValidationError
func (ValidationErrors) Errors ¶
func (v ValidationErrors) Errors() []string
Errors converts the slice into a string slice
Click to show internal directories.
Click to hide internal directories.