db

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db provides database helpers and models

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	ID            int `gorm:"primary_key"`
	UpdatedAt     time.Time
	ModifiedAt    time.Time
	LeftPath      string `gorm:"unique_index:idx_left_path_right_path"`
	RightPath     string `gorm:"not null; unique_index:idx_left_path_right_path" sql:"default: null"`
	RightPathUDec string `sql:"default: null"`
	Parent        *Album
	ParentID      int    `sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
	Cover         string `sql:"default: null"`
	TagArtist     *Artist
	TagArtistID   int `gorm:"index" sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
	TagGenre      *Genre
	TagGenreID    int    `sql:"default: null; type:int"`
	TagTitle      string `sql:"default: null"`
	TagTitleUDec  string `sql:"default: null"`
	TagBrainzID   string `sql:"default: null"`
	TagYear       int    `sql:"default: null"`
	Tracks        []*Track
	ChildCount    int  `sql:"-"`
	ReceivedPaths bool `gorm:"-"`
	ReceivedTags  bool `gorm:"-"`
}

func (*Album) IndexRightPath

func (a *Album) IndexRightPath() string

func (*Album) ParentSID added in v0.9.0

func (a *Album) ParentSID() *specid.ID

func (*Album) SID added in v0.9.0

func (a *Album) SID() *specid.ID

type Artist

type Artist struct {
	ID         int      `gorm:"primary_key"`
	Name       string   `gorm:"not null; unique_index"`
	NameUDec   string   `sql:"default: null"`
	Albums     []*Album `gorm:"foreignkey:TagArtistID"`
	AlbumCount int      `sql:"-"`
}

func (*Artist) IndexName

func (a *Artist) IndexName() string

func (*Artist) SID added in v0.9.0

func (a *Artist) SID() *specid.ID

type ChunkFunc added in v0.9.0

type ChunkFunc func(*gorm.DB, []int64) error

type DB

type DB struct {
	*gorm.DB
}

func New

func New(path string) (*DB, error)

func NewMock

func NewMock() (*DB, error)

func (*DB) GetOrCreateKey added in v0.9.0

func (db *DB) GetOrCreateKey(key string) string

func (*DB) GetSetting

func (db *DB) GetSetting(key string) string

func (*DB) GetUserByID added in v0.10.0

func (db *DB) GetUserByID(id int) *User

func (*DB) GetUserByName added in v0.10.0

func (db *DB) GetUserByName(name string) *User

func (*DB) SetSetting

func (db *DB) SetSetting(key, value string)

func (*DB) TransactionChunked added in v0.9.0

func (db *DB) TransactionChunked(data []int64, cb ChunkFunc) error

type Genre

type Genre struct {
	ID         int      `gorm:"primary_key"`
	Name       string   `gorm:"not null; unique_index"`
	Albums     []*Album `gorm:"foreignkey:TagGenreID"`
	AlbumCount int      `sql:"-"`
	Tracks     []*Track `gorm:"foreignkey:TagGenreID"`
	TrackCount int      `sql:"-"`
}

type Play

type Play struct {
	ID      int `gorm:"primary_key"`
	User    *User
	UserID  int `gorm:"not null; index" sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
	Album   *Album
	AlbumID int       `gorm:"not null; index" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
	Time    time.Time `sql:"default: null"`
	Count   int
}

type PlayQueue

type PlayQueue struct {
	ID        int `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	User      *User
	UserID    int `sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
	Current   int
	Position  int
	ChangedBy string
	Items     string
}

func (*PlayQueue) CurrentSID added in v0.9.4

func (p *PlayQueue) CurrentSID() *specid.ID

func (*PlayQueue) GetItems

func (p *PlayQueue) GetItems() []int

func (*PlayQueue) SetItems

func (p *PlayQueue) SetItems(items []int)

type Playlist

type Playlist struct {
	ID         int `gorm:"primary_key"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
	User       *User
	UserID     int `sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
	Name       string
	Comment    string
	TrackCount int
	Items      string
}

func (*Playlist) GetItems

func (p *Playlist) GetItems() []int

func (*Playlist) SetItems

func (p *Playlist) SetItems(items []int)

type Setting

type Setting struct {
	Key   string `gorm:"not null; primary_key; auto_increment:false" sql:"default: null"`
	Value string `sql:"default: null"`
}

type Track

type Track struct {
	ID             int `gorm:"primary_key"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
	Filename       string `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null"`
	FilenameUDec   string `sql:"default: null"`
	Album          *Album
	AlbumID        int `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
	Artist         *Artist
	ArtistID       int    `gorm:"not null" sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
	Size           int    `gorm:"not null" sql:"default: null"`
	Length         int    `sql:"default: null"`
	Bitrate        int    `sql:"default: null"`
	TagTitle       string `sql:"default: null"`
	TagTitleUDec   string `sql:"default: null"`
	TagTrackArtist string `sql:"default: null"`
	TagTrackNumber int    `sql:"default: null"`
	TagDiscNumber  int    `sql:"default: null"`
	TagGenre       *Genre
	TagGenreID     int    `sql:"default: null; type:int REFERENCES genres(id)"`
	TagBrainzID    string `sql:"default: null"`
}

func (*Track) AlbumSID added in v0.9.0

func (t *Track) AlbumSID() *specid.ID

func (*Track) ArtistSID added in v0.9.0

func (t *Track) ArtistSID() *specid.ID

func (*Track) Ext

func (t *Track) Ext() string

func (*Track) MIME

func (t *Track) MIME() string

func (*Track) RelPath

func (t *Track) RelPath() string

func (*Track) SID added in v0.9.0

func (t *Track) SID() *specid.ID

type TranscodePreference

type TranscodePreference struct {
	User    *User
	UserID  int    `gorm:"not null; unique_index:idx_user_id_client" sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
	Client  string `gorm:"not null; unique_index:idx_user_id_client" sql:"default: null"`
	Profile string `gorm:"not null" sql:"default: null"`
}

type User

type User struct {
	ID            int `gorm:"primary_key"`
	CreatedAt     time.Time
	Name          string `gorm:"not null; unique_index" sql:"default: null"`
	Password      string `gorm:"not null" sql:"default: null"`
	LastFMSession string `sql:"default: null"`
	IsAdmin       bool   `sql:"default: null"`
}

Jump to

Keyboard shortcuts

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