data

package
v0.0.0-...-af99189 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 ArticlesData interface {
	GetArticleByID(id int) (*Article, error)
	AddArticle(ar Article) error
	GetArticlesForTagAndDate(tag string, date string) ([]int, error)
	GetRelatedTagsForTag(tag string, articles []int) ([]string, error)
	Close()
}

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 NewValidation

func NewValidation() *Validation

NewValidation creates a new Validation type

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

Jump to

Keyboard shortcuts

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