db

package
v0.0.0-...-77c78fe Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connection

func Connection(c *m.Config) string

Connection creates the connection string and returns it.

Types

type DB

type DB struct {
	Conn  *gorm.DB
	Cache map[string]QueryCacheEntry
	// contains filtered or unexported fields
}

DB is the top-level DB interface

func Instance

func Instance() *DB

Instance return the global database instance

func New

func New() *DB

New returns a new empty DB instance

func (*DB) DefaultSettings

func (d *DB) DefaultSettings() m.Settings

DefaultSettings saves the default setting to the database, if there isn't a setting already

func (*DB) DeleteEntry

func (d *DB) DeleteEntry(hash string)

DeleteEntry deletes the entry identified by the provided hash

func (*DB) FileInDatabase

func (d *DB) FileInDatabase(hash, contentType string) bool

FileInDatabase checks if the file is already indexed and saved in the database

func (*DB) GetBrowseMovies

func (d *DB) GetBrowseMovies(media *[]m.Media)

GetBrowseMovies returns the first 25 movie entries from the database

func (*DB) GetBrowseShows

func (d *DB) GetBrowseShows(media *[]m.Media)

GetBrowseShows returns the first 25 show entries from the database

func (*DB) GetHomeMedia

func (d *DB) GetHomeMedia(media *[]m.Media)

GetHomeMedia returns the first 25 media entries from the database

func (*DB) GetMedia

func (d *DB) GetMedia(media *m.Media, hash string)

GetMedia returns the first media entry with the matching hash from the database

func (*DB) GetMedias

func (d *DB) GetMedias(media *[]m.Media, p [2]int)

GetMedias returns media entries from the database

func (*DB) GetMovie

func (d *DB) GetMovie(media *m.Media, hash string)

GetMovie returns the media entry (movie) with the matching hash from the database

func (*DB) GetMovieDetail

func (d *DB) GetMovieDetail(media *m.Media, hash string)

GetMovieDetail returns the full movie details by hash from the database

func (*DB) GetMovies

func (d *DB) GetMovies(media *[]m.Media, p [2]int)

GetMovies returns media entries (movies) from the database

func (*DB) GetShow

func (d *DB) GetShow(media *m.Media, hash string)

GetShow returns the media entry (show) with the matching hash from the database

func (*DB) GetShowDetail

func (d *DB) GetShowDetail(media *m.Media, hash string)

GetShowDetail returns the full show details by hash from the database

func (*DB) GetShows

func (d *DB) GetShows(media *[]m.Media, p [2]int)

GetShows returns media entries (shows) from the database

func (*DB) GetWatchedMedia

func (d *DB) GetWatchedMedia(w *[]m.Media)

GetWatchedMedia returns the currently watched media entries from the database

func (*DB) Init

func (d *DB) Init(c *m.Config)

Init sets up the database connection, sets table options, auto migrates models and initiates the query cache and will panic if it fails to connect

func (*DB) LoadSettings

func (d *DB) LoadSettings() m.Settings

LoadSettings loads the lastest setting entry out of the database

func (*DB) PurgeCache

func (d *DB) PurgeCache()

func (*DB) PurgeCacheEntries

func (d *DB) PurgeCacheEntries(keys ...string)

func (*DB) PurgeCacheEntry

func (d *DB) PurgeCacheEntry(key string)

func (*DB) Reactivate

func (d *DB) Reactivate(hash string)

func (*DB) SaveEntry

func (d *DB) SaveEntry(result *m.Result)

SaveEntry saves the provided result as a media entry to the database

func (*DB) SoftDeleted

func (d *DB) SoftDeleted(hash string) bool

SoftDeleted checks if the entry indentified by the provided hash is soft deleted

func (*DB) UpdateMovedEntry

func (d *DB) UpdateMovedEntry(hash, path, oldPath string)

UpdateMovedEntry updates the source path of the entry identified by the provided hash

type QueryCacheEntry

type QueryCacheEntry struct {
	Timestamp time.Time
	Content   interface{}
}

QueryCacheEntry describes a db query cache entry

func (QueryCacheEntry) IsStale

func (e QueryCacheEntry) IsStale() bool

IsStale returns wether the QueryCacheEntry is stale. A QueryCacheEntry is stale after 60 minutes

Jump to

Keyboard shortcuts

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