model

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 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")
)
View Source
var AnnotationFields = []string{"playCount", "playDate", "rating", "starred", "starredAt"}

While I can't find a better way to make these fields optional in the models, I keep this list here to be used in other packages

Functions

This section is empty.

Types

type Album

type Album struct {
	Annotations

	ID                   string    `json:"id"            orm:"column(id)"`
	Name                 string    `json:"name"`
	CoverArtPath         string    `json:"coverArtPath"`
	CoverArtId           string    `json:"coverArtId"`
	ArtistID             string    `json:"artistId"      orm:"pk;column(artist_id)"`
	Artist               string    `json:"artist"`
	AlbumArtistID        string    `json:"albumArtistId" orm:"pk;column(album_artist_id)"`
	AlbumArtist          string    `json:"albumArtist"`
	MaxYear              int       `json:"maxYear"`
	MinYear              int       `json:"minYear"`
	Compilation          bool      `json:"compilation"`
	SongCount            int       `json:"songCount"`
	Duration             float32   `json:"duration"`
	Genre                string    `json:"genre"`
	FullText             string    `json:"fullText"`
	SortAlbumName        string    `json:"sortAlbumName"`
	SortArtistName       string    `json:"sortArtistName"`
	SortAlbumArtistName  string    `json:"sortAlbumArtistName"`
	OrderAlbumName       string    `json:"orderAlbumName"`
	OrderAlbumArtistName string    `json:"orderAlbumArtistName"`
	CreatedAt            time.Time `json:"createdAt"`
	UpdatedAt            time.Time `json:"updatedAt"`
}

func (Album) GetAnnotations added in v0.20.0

func (a Album) GetAnnotations() Annotations

type AlbumRepository

type AlbumRepository interface {
	CountAll(...QueryOptions) (int64, error)
	Exists(id string) (bool, error)
	Get(id string) (*Album, error)
	FindByArtist(albumArtistId 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
	AnnotatedRepository
}

type Albums

type Albums []Album

type AnnotatedModel added in v0.20.0

type AnnotatedModel interface {
	GetAnnotations() Annotations
}

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

type Annotations struct {
	PlayCount int64     `json:"playCount"`
	PlayDate  time.Time `json:"playDate"`
	Rating    int       `json:"rating"`
	Starred   bool      `json:"starred"`
	StarredAt time.Time `json:"starredAt"`
}

type Artist

type Artist struct {
	Annotations

	ID              string `json:"id"          orm:"column(id)"`
	Name            string `json:"name"`
	AlbumCount      int    `json:"albumCount"`
	SongCount       int    `json:"songCount"`
	FullText        string `json:"fullText"`
	SortArtistName  string `json:"sortArtistName"`
	OrderArtistName string `json:"orderArtistName"`
}

func (Artist) GetAnnotations added in v0.20.0

func (a Artist) GetAnnotations() Annotations

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)
	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 {
	Annotations

	ID                   string    `json:"id"            orm:"pk;column(id)"`
	Path                 string    `json:"path"`
	Title                string    `json:"title"`
	Album                string    `json:"album"`
	ArtistID             string    `json:"artistId"      orm:"pk;column(artist_id)"`
	Artist               string    `json:"artist"`
	AlbumArtistID        string    `json:"albumArtistId"`
	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"`
	DiscSubtitle         string    `json:"discSubtitle"`
	Year                 int       `json:"year"`
	Size                 int64     `json:"size"`
	Suffix               string    `json:"suffix"`
	Duration             float32   `json:"duration"`
	BitRate              int       `json:"bitRate"`
	Genre                string    `json:"genre"`
	FullText             string    `json:"fullText"`
	SortTitle            string    `json:"sortTitle"`
	SortAlbumName        string    `json:"sortAlbumName"`
	SortArtistName       string    `json:"sortArtistName"`
	SortAlbumArtistName  string    `json:"sortAlbumArtistName"`
	OrderAlbumName       string    `json:"orderAlbumName"`
	OrderArtistName      string    `json:"orderArtistName"`
	OrderAlbumArtistName string    `json:"orderAlbumArtistName"`
	Compilation          bool      `json:"compilation"`
	CreatedAt            time.Time `json:"createdAt"`
	UpdatedAt            time.Time `json:"updatedAt"`
}

func (*MediaFile) ContentType

func (mf *MediaFile) ContentType() string

func (MediaFile) GetAnnotations added in v0.20.0

func (mf MediaFile) GetAnnotations() Annotations

type MediaFileRepository

type MediaFileRepository interface {
	CountAll(options ...QueryOptions) (int64, error)
	Exists(id string) (bool, error)
	Put(m *MediaFile) error
	Get(id string) (*MediaFile, error)
	GetAll(options ...QueryOptions) (MediaFiles, 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   int32
	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     `json:"id"          orm:"column(id)"`
	Name      string     `json:"name"`
	Comment   string     `json:"comment"`
	Duration  float32    `json:"duration"`
	SongCount int        `json:"songCount"`
	Owner     string     `json:"owner"`
	Public    bool       `json:"public"`
	Tracks    MediaFiles `json:"tracks,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
}

type PlaylistRepository

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

type PlaylistTrack added in v0.19.0

type PlaylistTrack struct {
	ID          string `json:"id"          orm:"column(id)"`
	MediaFileID string `json:"mediaFileId" orm:"column(media_file_id)"`
	PlaylistID  string `json:"playlistId" orm:"column(playlist_id)"`
	MediaFile
}

type PlaylistTrackRepository added in v0.19.0

type PlaylistTrackRepository interface {
	ResourceRepository
	Add(mediaFileIds []string) error
	Update(mediaFileIds []string) error
	Delete(id string) error
}

type PlaylistTracks added in v0.19.0

type PlaylistTracks []PlaylistTrack

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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