db

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album added in v0.7.1

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 `sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
	TagGenre      *Genre
	TagGenreID    int    `sql:"default: null; type:int REFERENCES genres(id) ON DELETE CASCADE"`
	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 added in v0.7.1

func (a *Album) IndexRightPath() string

type Artist added in v0.7.1

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 added in v0.7.1

func (a *Artist) IndexName() string

type DB

type DB struct {
	*gorm.DB
}

func New

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

func NewMock

func NewMock() (*DB, error)

func (*DB) GetSetting

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

func (*DB) GetUserFromName

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

func (*DB) SetSetting

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

func (*DB) WithTx

func (db *DB) WithTx(cb func(tx *gorm.DB))

type Genre added in v0.8.2

type Genre struct {
	ID         int      `gorm:"primary_ket"`
	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 added in v0.7.1

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 added in v0.7.1

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) GetItems added in v0.7.1

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

func (*PlayQueue) SetItems added in v0.7.1

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

type Playlist added in v0.7.1

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 added in v0.7.1

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

func (*Playlist) SetItems added in v0.7.1

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

type Setting added in v0.7.1

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

type Track added in v0.7.1

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) ON DELETE CASCADE"`
	TagBrainzID    string `sql:"default: null"`
}

func (*Track) Ext added in v0.7.1

func (t *Track) Ext() string

func (*Track) MIME added in v0.7.1

func (t *Track) MIME() string

func (*Track) RelPath added in v0.8.2

func (t *Track) RelPath() string

type TranscodePreference added in v0.8.2

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

type User added in v0.7.1

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