database

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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) 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) 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) ([]Album, error)

func (*Database) GetAllArtists added in v0.6.0

func (db *Database) GetAllArtists(ctx context.Context) ([]Artist, 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, random bool) ([]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) 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) GetTrackByPath added in v0.6.0

func (db *Database) GetTrackByPath(ctx context.Context, path string) (Track, 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) 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) 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 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
}

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

type User struct {
	Id       string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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