model

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PropLastScan = "LastScan"
)

Variables

View Source
var (
	ErrNotFound      = errors.New("data not found")
	ErrInvalidAuth   = errors.New("invalid authentication")
	ErrNotAuthorized = errors.New("not authorized")
)

Functions

This section is empty.

Types

type Album

type Album struct {
	ID           string    `json:"id"            orm:"column(id)"`
	Name         string    `json:"name"`
	ArtistID     string    `json:"artistId"      orm:"pk;column(artist_id)"`
	CoverArtPath string    `json:"coverArtPath"`
	CoverArtId   string    `json:"coverArtId"`
	Artist       string    `json:"artist"`
	AlbumArtist  string    `json:"albumArtist"`
	Year         int       `json:"year"`
	Compilation  bool      `json:"compilation"`
	SongCount    int       `json:"songCount"`
	Duration     float32   `json:"duration"`
	Genre        string    `json:"genre"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`

	// Annotations
	PlayCount int       `json:"-"   orm:"-"`
	PlayDate  time.Time `json:"-"   orm:"-"`
	Rating    int       `json:"-"   orm:"-"`
	Starred   bool      `json:"-"   orm:"-"`
	StarredAt time.Time `json:"-"   orm:"-"`
}

type AlbumRepository

type AlbumRepository interface {
	CountAll(...QueryOptions) (int64, error)
	Exists(id string) (bool, error)
	Put(m *Album) error
	Get(id string) (*Album, error)
	FindByArtist(artistId string) (Albums, error)
	GetAll(...QueryOptions) (Albums, error)
	GetRandom(...QueryOptions) (Albums, error)
	GetStarred(options ...QueryOptions) (Albums, error)
	Search(q string, offset int, size int) (Albums, error)
	Refresh(ids ...string) error
	PurgeEmpty() error
	AnnotatedRepository
}

type Albums

type Albums []Album

type AnnotatedRepository added in v0.5.0

type AnnotatedRepository interface {
	IncPlayCount(itemID string, ts time.Time) error
	SetStar(starred bool, itemIDs ...string) error
	SetRating(rating int, itemID string) error
}

type Artist

type Artist struct {
	ID         string `json:"id"          orm:"column(id)"`
	Name       string `json:"name"`
	AlbumCount int    `json:"albumCount"  orm:"column(album_count)"`

	// Annotations
	PlayCount int       `json:"-"   orm:"-"`
	PlayDate  time.Time `json:"-"   orm:"-"`
	Rating    int       `json:"-"   orm:"-"`
	Starred   bool      `json:"-"   orm:"-"`
	StarredAt time.Time `json:"-"   orm:"-"`
}

type ArtistIndex

type ArtistIndex struct {
	ID      string
	Artists Artists
}

type ArtistIndexes

type ArtistIndexes []ArtistIndex

type ArtistRepository

type ArtistRepository interface {
	CountAll(options ...QueryOptions) (int64, error)
	Exists(id string) (bool, error)
	Put(m *Artist) error
	Get(id string) (*Artist, error)
	GetStarred(options ...QueryOptions) (Artists, error)
	Search(q string, offset int, size int) (Artists, error)
	Refresh(ids ...string) error
	GetIndex() (ArtistIndexes, error)
	PurgeEmpty() error
	AnnotatedRepository
}

type Artists

type Artists []Artist

type DataStore

type DataStore interface {
	Album(ctx context.Context) AlbumRepository
	Artist(ctx context.Context) ArtistRepository
	MediaFile(ctx context.Context) MediaFileRepository
	MediaFolder(ctx context.Context) MediaFolderRepository
	Genre(ctx context.Context) GenreRepository
	Playlist(ctx context.Context) PlaylistRepository
	Property(ctx context.Context) PropertyRepository
	User(ctx context.Context) UserRepository
	Transcoding(ctx context.Context) TranscodingRepository
	Player(ctx context.Context) PlayerRepository

	Resource(ctx context.Context, model interface{}) ResourceRepository

	WithTx(func(tx DataStore) error) error
	GC(ctx context.Context) error
}

type Genre

type Genre struct {
	Name       string
	SongCount  int
	AlbumCount int
}

type GenreRepository

type GenreRepository interface {
	GetAll() (Genres, error)
}

type Genres

type Genres []Genre

type MediaFile

type MediaFile struct {
	ID          string    `json:"id"            orm:"pk;column(id)"`
	Path        string    `json:"path"`
	Title       string    `json:"title"`
	Album       string    `json:"album"`
	Artist      string    `json:"artist"`
	ArtistID    string    `json:"artistId"      orm:"pk;column(artist_id)"`
	AlbumArtist string    `json:"albumArtist"`
	AlbumID     string    `json:"albumId"       orm:"pk;column(album_id)"`
	HasCoverArt bool      `json:"hasCoverArt"`
	TrackNumber int       `json:"trackNumber"`
	DiscNumber  int       `json:"discNumber"`
	Year        int       `json:"year"`
	Size        int       `json:"size"`
	Suffix      string    `json:"suffix"`
	Duration    float32   `json:"duration"`
	BitRate     int       `json:"bitRate"`
	Genre       string    `json:"genre"`
	Compilation bool      `json:"compilation"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`

	// Annotations
	PlayCount int       `json:"-"   orm:"-"`
	PlayDate  time.Time `json:"-"   orm:"-"`
	Rating    int       `json:"-"   orm:"-"`
	Starred   bool      `json:"-"   orm:"-"`
	StarredAt time.Time `json:"-"   orm:"-"`
}

func (*MediaFile) ContentType

func (mf *MediaFile) ContentType() string

type MediaFileRepository

type MediaFileRepository interface {
	CountAll(options ...QueryOptions) (int64, error)
	Exists(id string) (bool, error)
	Put(m *MediaFile) error
	Get(id string) (*MediaFile, error)
	FindByAlbum(albumId string) (MediaFiles, error)
	FindByPath(path string) (MediaFiles, error)
	GetStarred(options ...QueryOptions) (MediaFiles, error)
	GetRandom(options ...QueryOptions) (MediaFiles, error)
	Search(q string, offset int, size int) (MediaFiles, error)
	Delete(id string) error
	DeleteByPath(path string) error

	AnnotatedRepository
}

type MediaFiles

type MediaFiles []MediaFile

type MediaFolder

type MediaFolder struct {
	ID   string
	Name string
	Path string
}

type MediaFolderRepository

type MediaFolderRepository interface {
	Get(id string) (*MediaFolder, error)
	GetAll() (MediaFolders, error)
}

type MediaFolders

type MediaFolders []MediaFolder

type Player added in v0.10.0

type Player struct {
	ID            string    `json:"id"            orm:"column(id)"`
	Name          string    `json:"name"`
	Type          string    `json:"type"`
	UserName      string    `json:"userName"`
	Client        string    `json:"client"`
	IPAddress     string    `json:"ipAddress"`
	LastSeen      time.Time `json:"lastSeen"`
	TranscodingId string    `json:"transcodingId"`
	MaxBitRate    int       `json:"maxBitRate"`
}

type PlayerRepository added in v0.10.0

type PlayerRepository interface {
	Get(id string) (*Player, error)
	FindByName(client, userName string) (*Player, error)
	Put(p *Player) error
}

type Players added in v0.10.0

type Players []Player

type Playlist

type Playlist struct {
	ID       string
	Name     string
	Comment  string
	Duration float32
	Owner    string
	Public   bool
	Tracks   MediaFiles
}

type PlaylistRepository

type PlaylistRepository interface {
	CountAll() (int64, error)
	Exists(id string) (bool, error)
	Put(pls *Playlist) error
	Get(id string) (*Playlist, error)
	GetWithTracks(id string) (*Playlist, error)
	GetAll(options ...QueryOptions) (Playlists, error)
	Delete(id string) error
}

type Playlists

type Playlists []Playlist

type Property

type Property struct {
	ID    string
	Value string
}

type PropertyRepository

type PropertyRepository interface {
	Put(id string, value string) error
	Get(id string) (string, error)
	DefaultGet(id string, defaultValue string) (string, error)
}

type QueryOptions

type QueryOptions struct {
	Sort    string
	Order   string
	Max     int
	Offset  int
	Filters squirrel.Sqlizer
}

type ResourceRepository

type ResourceRepository interface {
	rest.Repository
}

type Transcoding added in v0.10.0

type Transcoding struct {
	ID             string `json:"id"            orm:"column(id)"`
	Name           string `json:"name"`
	TargetFormat   string `json:"targetFormat"`
	Command        string `json:"command"`
	DefaultBitRate int    `json:"defaultBitRate"`
}

type TranscodingRepository added in v0.10.0

type TranscodingRepository interface {
	Get(id string) (*Transcoding, error)
	CountAll(...QueryOptions) (int64, error)
	Put(*Transcoding) error
	FindByFormat(format string) (*Transcoding, error)
}

type Transcodings added in v0.10.0

type Transcodings []Transcoding

type User

type User struct {
	ID           string     `json:"id" orm:"column(id)"`
	UserName     string     `json:"userName"`
	Name         string     `json:"name"`
	Email        string     `json:"email"`
	Password     string     `json:"password"`
	IsAdmin      bool       `json:"isAdmin"`
	LastLoginAt  *time.Time `json:"lastLoginAt"`
	LastAccessAt *time.Time `json:"lastAccessAt"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
}

type UserRepository

type UserRepository interface {
	CountAll(...QueryOptions) (int64, error)
	Get(id string) (*User, error)
	Put(*User) error
	// FindByUsername must be case-insensitive
	FindByUsername(username string) (*User, error)
	UpdateLastLoginAt(id string) error
	UpdateLastAccessAt(id string) error
}

type Users added in v0.5.0

type Users []User

Jump to

Keyboard shortcuts

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