subscription

package
v0.0.0-...-473f5cf Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package subscription holds the data types for subscriptions and podcast episodes

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSubNotFound is the error returned for when searching subscriptions by tag returned no results
	ErrSubNotFound = errors.New("Subscription tag was not found")
)

Functions

func AllTypes

func AllTypes() []interface{}

AllTypes returns all the database types defined in this package

Types

type Episode

type Episode struct {
	ID             uint `gorm:"primarykey"`
	SubscriptionID int
	Title          string
	URL            string `gorm:"unique"`
	PublishedAt    time.Time
}

Episode contains the information about a single podcast episode

type SubHandler

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

SubHandler is a sub data handler, in charge of data access methods for the subscription data types

func Handler

func Handler(db *gorm.DB) SubHandler

Handler creates a new subscription handler from the given gorm object

func (SubHandler) AddEpisodes

func (s SubHandler) AddEpisodes(sub Subscription, eps []Episode) error

AddEpisodes adds the given episodes to the database

func (SubHandler) GetSubscriptionByTag

func (s SubHandler) GetSubscriptionByTag(tag string) (Subscription, error)

GetSubscriptionByTag returns a subscription by its tag

func (SubHandler) GetSubscriptions

func (s SubHandler) GetSubscriptions() ([]Subscription, error)

GetSubscriptions returns an array of every subscription

func (SubHandler) GetSubscriptionsByTags

func (s SubHandler) GetSubscriptionsByTags(tags ...string) ([]Subscription, error)

GetSubscriptionsByTags returns all subscribtions with the given tags

func (SubHandler) NewSubscription

func (s SubHandler) NewSubscription(sub *Subscription) error

NewSubscription adds the given subscription to the database as a new entry

func (SubHandler) RemoveEpisodes

func (s SubHandler) RemoveEpisodes(eps []Episode) error

RemoveEpisodes removes the given episodes from the database

func (SubHandler) RemoveSubscriptions

func (s SubHandler) RemoveSubscriptions(subs []Subscription) error

RemoveSubscriptions removes the given subscriptions from the database

func (SubHandler) UpdateSubscription

func (s SubHandler) UpdateSubscription(sub Subscription) error

UpdateSubscription saves changes to this subscription to the database

type Subscription

type Subscription struct {
	ID        uint `gorm:"primarykey"`
	UpdatedAt time.Time
	Name      string
	RSSURL    string    `gorm:"unique"`
	Tag       string    `gorm:"unique"`
	Episodes  []Episode `gorm:"foreignKey:SubscriptionID"`
}

Subscription is the data type for podcast subscriptions

Jump to

Keyboard shortcuts

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