database

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FullParseFilter added in v0.11.0

func FullParseFilter(adapter filter.ResolverAdapter, filterStr string) (exp.Expression, error)

func TrackMapNameToId added in v0.11.0

func TrackMapNameToId(typ string, name string) string

Types

type Album

type Album struct {
	Id       string
	Name     string
	CoverArt sql.NullString
	ArtistId string
	Path     string
}

type AlbumChanges added in v0.7.0

type AlbumChanges struct {
	Name      types.Change[string]
	CoverArt  types.Change[sql.NullString]
	Available bool
}

type AlbumResolverAdapter added in v0.11.0

type AlbumResolverAdapter struct {
}

func (*AlbumResolverAdapter) GetDefaultSort added in v0.11.0

func (a *AlbumResolverAdapter) GetDefaultSort() string

func (*AlbumResolverAdapter) MapName added in v0.11.0

func (a *AlbumResolverAdapter) MapName(name string) (filter.Name, error)

func (*AlbumResolverAdapter) MapNameToId added in v0.11.0

func (a *AlbumResolverAdapter) MapNameToId(typ, name string) (string, error)

func (*AlbumResolverAdapter) ResolveFunctionCall added in v0.11.0

func (a *AlbumResolverAdapter) ResolveFunctionCall(resolver *filter.Resolver, name string, args []ast.Expr) (filter.FilterExpr, error)

func (*AlbumResolverAdapter) ResolveTable added in v0.11.0

func (a *AlbumResolverAdapter) ResolveTable(typ string) (filter.Table, error)

type Artist

type Artist struct {
	Id      string
	Name    string
	Picture sql.NullString
	Path    string
}

type ArtistChanges added in v0.7.0

type ArtistChanges struct {
	Name      types.Change[string]
	Picture   types.Change[sql.NullString]
	Available bool
}

type Config added in v0.10.0

type Config struct {
	OwnerId string
}

type Connection added in v0.10.0

type Connection interface {
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
	Exec(query string, args ...any) (sql.Result, error)
}

type CreateAlbumParams

type CreateAlbumParams struct {
	Name     string
	CoverArt sql.NullString
	ArtistId string
	Path     string
}

type CreateArtistParams

type CreateArtistParams struct {
	Name    string
	Picture sql.NullString
	Path    string
}

type CreatePlaylistParams added in v0.10.0

type CreatePlaylistParams struct {
	Name    string
	OwnerId string
}

type CreateTrackParams

type CreateTrackParams struct {
	TrackNumber       int
	Name              string
	CoverArt          sql.NullString
	Path              string
	Duration          int
	BestQualityFile   string
	MobileQualityFile string
	AlbumId           string
	ArtistId          string
}

type Database added in v0.6.0

type Database struct {
	RawConn *sql.DB
	Conn    Connection
}

func New

func New(conn *sql.DB) *Database

func Open added in v0.10.0

func Open(workDir types.WorkDir) (*Database, error)

func (*Database) AddGenreToTrack added in v0.11.0

func (db *Database) AddGenreToTrack(ctx context.Context, genreId, trackId string) error

func (*Database) AddItemsToPlaylist added in v0.10.0

func (db *Database) AddItemsToPlaylist(ctx context.Context, playlistId string, trackIds []string) error

func (*Database) AddTagToTrack added in v0.8.0

func (db *Database) AddTagToTrack(ctx context.Context, tagId, trackId string) error

func (*Database) Begin added in v0.10.0

func (db *Database) Begin() (*Database, *sql.Tx, error)

func (*Database) CreateAlbum added in v0.6.0

func (db *Database) CreateAlbum(ctx context.Context, params CreateAlbumParams) (Album, error)

func (*Database) CreateArtist added in v0.6.0

func (db *Database) CreateArtist(ctx context.Context, params CreateArtistParams) (Artist, error)

func (*Database) CreateConfig added in v0.10.0

func (db *Database) CreateConfig(ctx context.Context, ownerId string) (Config, error)

func (*Database) CreateGenre added in v0.11.0

func (db *Database) CreateGenre(ctx context.Context, name string) (Genre, error)

func (*Database) CreatePlaylist added in v0.10.0

func (db *Database) CreatePlaylist(ctx context.Context, params CreatePlaylistParams) (Playlist, error)

func (*Database) CreateTag added in v0.8.0

func (db *Database) CreateTag(ctx context.Context, name string) (Tag, error)

func (*Database) CreateTrack added in v0.6.0

func (db *Database) CreateTrack(ctx context.Context, params CreateTrackParams) (Track, error)

func (*Database) CreateUser added in v0.10.0

func (db *Database) CreateUser(ctx context.Context, username, password string) (User, error)

func (*Database) DeleteItemsFromPlaylist added in v0.10.0

func (db *Database) DeleteItemsFromPlaylist(ctx context.Context, playlistId string, trackIndices []int) error

TODO(patrik): Change from trackIndices to trackIds

func (*Database) Exec added in v0.6.0

func (db *Database) Exec(ctx context.Context, s ToSQL) (sql.Result, error)

func (*Database) GetAlbumById added in v0.6.0

func (db *Database) GetAlbumById(ctx context.Context, id string) (Album, error)

func (*Database) GetAlbumByName added in v0.10.0

func (db *Database) GetAlbumByName(ctx context.Context, name string) (Album, error)

func (*Database) GetAlbumByPath added in v0.6.0

func (db *Database) GetAlbumByPath(ctx context.Context, path string) (Album, error)

func (*Database) GetAlbumsByArtist added in v0.6.0

func (db *Database) GetAlbumsByArtist(ctx context.Context, artistId string) ([]Album, error)

func (*Database) GetAllAlbums added in v0.6.0

func (db *Database) GetAllAlbums(ctx context.Context, filterStr string) ([]Album, error)

func (*Database) GetAllArtists added in v0.6.0

func (db *Database) GetAllArtists(ctx context.Context) ([]Artist, error)

func (*Database) GetAllGenres added in v0.11.0

func (db *Database) GetAllGenres(ctx context.Context) ([]Genre, error)

func (*Database) GetAllTags added in v0.9.0

func (db *Database) GetAllTags(ctx context.Context) ([]Tag, error)

func (*Database) GetAllTracks added in v0.6.0

func (db *Database) GetAllTracks(ctx context.Context, filterStr string, sortStr string) ([]Track, error)

func (*Database) GetArtistById added in v0.6.0

func (db *Database) GetArtistById(ctx context.Context, id string) (Artist, error)

func (*Database) GetArtistByName added in v0.8.0

func (db *Database) GetArtistByName(ctx context.Context, name string) (Artist, error)

func (*Database) GetArtistByPath added in v0.6.0

func (db *Database) GetArtistByPath(ctx context.Context, path string) (Artist, error)

func (*Database) GetConfig added in v0.10.0

func (db *Database) GetConfig(ctx context.Context) (*Config, error)

func (*Database) GetGenreByName added in v0.11.0

func (db *Database) GetGenreByName(ctx context.Context, name string) (Genre, error)

func (*Database) GetPlaylistById added in v0.10.0

func (db *Database) GetPlaylistById(ctx context.Context, id string) (Playlist, error)

func (*Database) GetPlaylistItems added in v0.10.0

func (db *Database) GetPlaylistItems(ctx context.Context, playlistId string) ([]PlaylistItem, error)

func (*Database) GetPlaylistsByUser added in v0.10.0

func (db *Database) GetPlaylistsByUser(ctx context.Context, userId string) ([]Playlist, error)

func (*Database) GetTagByName added in v0.8.0

func (db *Database) GetTagByName(ctx context.Context, name string) (Tag, error)

func (*Database) GetTrackById added in v0.6.0

func (db *Database) GetTrackById(ctx context.Context, id string) (Track, error)

func (*Database) GetTrackByName added in v0.10.0

func (db *Database) GetTrackByName(ctx context.Context, name string) (Track, error)

func (*Database) GetTrackByNameAndAlbum added in v0.11.0

func (db *Database) GetTrackByNameAndAlbum(ctx context.Context, name string, albumId string) (Track, error)

func (*Database) GetTrackByPath added in v0.6.0

func (db *Database) GetTrackByPath(ctx context.Context, path string) (Track, error)

func (*Database) GetTrackGenres added in v0.11.0

func (db *Database) GetTrackGenres(ctx context.Context, trackId string) ([]Genre, error)

func (*Database) GetTrackTags added in v0.8.0

func (db *Database) GetTrackTags(ctx context.Context, trackId string) ([]Tag, error)

func (*Database) GetTracksByAlbum added in v0.6.0

func (db *Database) GetTracksByAlbum(ctx context.Context, albumId string) ([]Track, error)

func (*Database) GetUserById added in v0.10.0

func (db *Database) GetUserById(ctx context.Context, id string) (User, error)

func (*Database) GetUserByUsername added in v0.10.0

func (db *Database) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Database) Invalidate added in v0.11.0

func (db *Database) Invalidate()

func (*Database) MarkAllAlbumsUnavailable added in v0.7.0

func (db *Database) MarkAllAlbumsUnavailable(ctx context.Context) error

func (*Database) MarkAllArtistsUnavailable added in v0.7.0

func (db *Database) MarkAllArtistsUnavailable(ctx context.Context) error

func (*Database) MarkAllTracksUnavailable added in v0.7.0

func (db *Database) MarkAllTracksUnavailable(ctx context.Context) error

func (*Database) MovePlaylistItem added in v0.10.0

func (db *Database) MovePlaylistItem(ctx context.Context, playlistId string, trackId string, toIndex int) error

TODO(patrik): Add bounds check for toIndex

func (*Database) Query added in v0.6.0

func (db *Database) Query(ctx context.Context, s ToSQL) (*sql.Rows, error)

func (*Database) QueryRow added in v0.6.0

func (db *Database) QueryRow(ctx context.Context, s ToSQL) (*sql.Row, error)

func (*Database) RemoveGenreFromTrack added in v0.11.0

func (db *Database) RemoveGenreFromTrack(ctx context.Context, genreId, trackId string) error

func (*Database) RemoveTagFromTrack added in v0.8.0

func (db *Database) RemoveTagFromTrack(ctx context.Context, tagId, trackId string) error

func (*Database) UpdateAlbum added in v0.7.0

func (db *Database) UpdateAlbum(ctx context.Context, id string, changes AlbumChanges) error

func (*Database) UpdateArtist added in v0.7.0

func (db *Database) UpdateArtist(ctx context.Context, id string, changes ArtistChanges) error

func (*Database) UpdateTrack added in v0.6.0

func (db *Database) UpdateTrack(ctx context.Context, id string, changes TrackChanges) error

type Genre added in v0.11.0

type Genre struct {
	Id          string
	Name        string
	DisplayName string
}

type Playlist added in v0.10.0

type Playlist struct {
	Id      string
	Name    string
	OwnerId string
}

type PlaylistItem added in v0.10.0

type PlaylistItem struct {
	PlaylistId string
	TrackId    string
	ItemIndex  int
}

type Tag added in v0.8.0

type Tag struct {
	Id          string
	Name        string
	DisplayName string
}

type ToSQL added in v0.6.0

type ToSQL interface {
	ToSQL() (string, []interface{}, error)
}

type Track

type Track struct {
	Id       string
	Number   int
	Name     string
	CoverArt sql.NullString
	Duration int

	Path string

	BestQualityFile   string
	MobileQualityFile string

	AlbumId  string
	ArtistId string

	AlbumName  string
	ArtistName string
}

type TrackChanges added in v0.7.0

type TrackChanges struct {
	Number            types.Change[int]
	Name              types.Change[string]
	CoverArt          types.Change[sql.NullString]
	Duration          types.Change[int]
	BestQualityFile   types.Change[string]
	MobileQualityFile types.Change[string]
	ArtistId          types.Change[string]
	Available         bool
}

type TrackResolverAdapter added in v0.11.0

type TrackResolverAdapter struct {
}

func (*TrackResolverAdapter) GetDefaultSort added in v0.11.0

func (a *TrackResolverAdapter) GetDefaultSort() string

func (*TrackResolverAdapter) MapName added in v0.11.0

func (a *TrackResolverAdapter) MapName(name string) (filter.Name, error)

func (*TrackResolverAdapter) MapNameToId added in v0.11.0

func (a *TrackResolverAdapter) MapNameToId(typ, name string) (string, error)

func (*TrackResolverAdapter) ResolveFunctionCall added in v0.11.0

func (a *TrackResolverAdapter) ResolveFunctionCall(resolver *filter.Resolver, name string, args []ast.Expr) (filter.FilterExpr, error)

func (*TrackResolverAdapter) ResolveTable added in v0.11.0

func (a *TrackResolverAdapter) ResolveTable(typ string) (filter.Table, error)

type User added in v0.10.0

type User struct {
	Id       string
	Username string
	Password string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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