models

package
v0.0.0-...-1a79bca Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 7 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 {
	URL            string   `bson:"url,omitempty" json:"url"`
	Title          string   `bson:"title,omitempty" json:"title"`
	Section        string   `bson:"section,omitempty" json:"section"`
	PublishedDate  string   `bson:"date_created,omitempty" json:"published_date"`
	Text           string   `bson:"text,omitempty" json:"-"`
	SummarisedText string   `bson:"summarised_text,omitempty"`
	Tags           []string `bson:"tags,omitempty"`
}

The document that goes into the (mongo) database.

type ArticleDB

type ArticleDB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() *ArticleDB

func (*ArticleDB) AllArticles

func (adb *ArticleDB) AllArticles() ([]Article, error)

func (*ArticleDB) BySections

func (adb *ArticleDB) BySections(sections []string) ([]Article, error)

Query the articles by sections

func (*ArticleDB) BySectionsAndTags

func (adb *ArticleDB) BySectionsAndTags(sections []string, tags []string) ([]Article, error)

Query the articles by tags and sections

func (*ArticleDB) ByTags

func (adb *ArticleDB) ByTags(tags []string) ([]Article, error)

Query the articles by tags

func (*ArticleDB) ByURL

func (adb *ArticleDB) ByURL(url string) (*Article, error)

ByURL is used in controller packages to check for existing article, assuming the URL of the article never changed and each article has an unique url.

func (*ArticleDB) CleanOldArticles

func (adb *ArticleDB) CleanOldArticles(numberOfArticles int, logger *log.Logger)

Delete old articles

func (*ArticleDB) Close

func (adb *ArticleDB) Close() error

func (*ArticleDB) DestructiveReset

func (adb *ArticleDB) DestructiveReset() error

Remove all documents in "articles" collection by dropping the collection and create it again.

func (*ArticleDB) Init

func (adb *ArticleDB) Init(uri string) error

func (*ArticleDB) InsertArticle

func (adb *ArticleDB) InsertArticle(a Article) error

Insert an article/document into the mongo database

type Articles

type Articles []Article

func (Articles) Len

func (as Articles) Len() int

func (Articles) Less

func (as Articles) Less(i, j int) bool

func (Articles) Swap

func (as Articles) Swap(i, j int)

Jump to

Keyboard shortcuts

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