models

package
v0.0.0-...-5d5cde0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const NewsByID = `SELECT s.rss, s.name, n.name FROM section s INNER JOIN newspaper n ON(s.newspaper_id = n.id) WHERE s.id=?1`

NewsByID returns a RSS url for a section.id

View Source
const NewspaperByID = `SELECT n.id, n.name, c.name, c.code FROM newspaper n INNER JOIN country c ON(n.country_id = c.id) WHERE n.id=?1`

NewspaperByID returns a single newspaper filtering by newspaper.id

View Source
const NewspapersAll = `SELECT n.id, n.name, c.name, c.code FROM newspaper n INNER JOIN country c ON(n.country_id = c.id)`

NewspapersAll returns a list of newspapers for all the newspapers in the database

View Source
const NewspapersByCountry = `` /* 132-byte string literal not displayed */

NewspapersByCountry returns a list of newspapers filtering by country.code

View Source
const NewspapersByName = `` /* 139-byte string literal not displayed */

NewspapersByName returns a list of newspapers filtering by newspaper.name

View Source
const SectionsByName = `` /* 283-byte string literal not displayed */

SectionsByName is used for return a list of sections filtering by section.name

View Source
const SectionsByNewspaper = `` /* 213-byte string literal not displayed */

SectionsByNewspaper is used for return a list of sections by newspaper.id

View Source
const SectionsByTags = `` /* 149-byte string literal not displayed */

SectionsByTags const

View Source
const TagsIDs = `SELECT id FROM category WHERE UPPER(name) in (?1)`

TagsIDs returns the category ids for a list of tags

Variables

This section is empty.

Functions

func AttachFilter

func AttachFilter(db *sql.DB, userID int64, filterID int64) (int64, error)

func DetachFilter

func DetachFilter(db *sql.DB, userID int64, filterID int64) (int64, error)

func GetIDsFromTags

func GetIDsFromTags(db *sql.DB, tags string) []int

func LoginUser

func LoginUser(db *sql.DB, username string, password string) (string, error)

func PostFilter

func PostFilter(db *sql.DB, filter string, userID int64) (int64, error)

func PostUser

func PostUser(db *sql.DB, email string, username string, password string) (int64, error)

func Subscribe

func Subscribe(db *sql.DB, sectionID int64, userID int64, subscribe bool) (int64, error)

Types

type Filter

type Filter struct {
	ID     int64  `json:"id"`
	Filter string `json:"name"`
}

type FilterCollection

type FilterCollection struct {
	Filters []Filter `json:"filters"`
}

func GetFilters

func GetFilters(db *sql.DB) FilterCollection

type News

type News struct {
	Title        string `json:"title"`
	Descripition string `json:"description"`
	Link         string `json:"link"`
	Newspaper    string `json:"newspaper"`
	Section      string `json:"section"`
}

func GetFilteredNews

func GetFilteredNews(db *sql.DB, id int64, filter string) []News

func GetMultipleNews

func GetMultipleNews(db *sql.DB, sections string, filter string) []News

func GetNews

func GetNews(db *sql.DB, userID int64) []News

func GetNewsBySection

func GetNewsBySection(db *sql.DB, id int64) []News

type Newspaper

type Newspaper struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Country     string    `json:"country"`
	CountryCode string    `json:"contry_code"`
	Sections    []Section `json:"sections"`
}

func GetNewspaper

func GetNewspaper(db *sql.DB, id int, userID int64) Newspaper

type Newspapers

type Newspapers struct {
	Newspapers []Newspaper `json:"items"`
}

func GetNewspapers

func GetNewspapers(db *sql.DB) Newspapers

func GetNewspapersByCountry

func GetNewspapersByCountry(db *sql.DB, countryCode string) Newspapers

func GetNewspapersByName

func GetNewspapersByName(db *sql.DB, name string) Newspapers

type Section

type Section struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	RSS        string `json:"rss"`
	Failed     bool   `json:"failed"`
	Newspaper  string `json:"newspaper"`
	Subscribed bool   `json:"subscribed"`
}

Section contains information related to the section table in the database

type Sections

type Sections struct {
	Sections []Section `json:"sections"`
}

Sections is a list of Section

func GetSectionsByName

func GetSectionsByName(db *sql.DB, name string, userID int64) Sections

GetSectionsByName returns an instance of Sections filtered by section name

func GetSectionsByNewspaper

func GetSectionsByNewspaper(db *sql.DB, newspaperID int, userID int64) Sections

GetSectionsByNewspaper returns an instance of Sections filtered by newspaperID

func GetSectionsByTags

func GetSectionsByTags(db *sql.DB, tags string) Sections

GetSectionsByTags returns an instances of Sections that are mapped to a tag

Jump to

Keyboard shortcuts

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