db

package
v0.1.0-nightly Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDatabase

func ConnectDatabase() error

func GetAllPlayables

func GetAllPlayables() ([]types.Playable, error)

TODO: Add a way to filter the types of playables that are returned so we don't perform unnecessary database queries

func GetPlayables

func GetPlayables(userID string) ([]types.Playable, error)

TODO: Add a way to filter the types of playables that are returned so we don't perform unnecessary database queries

Types

type Database

type Database interface {
	Connect() error
	Close() error
	EngineName() string

	MigrateUp(steps int) error
	MigrateDown(steps int) error

	GetAllTracks() ([]types.Track, error)
	GetTracks(userID string) ([]types.Track, error)
	GetTrack(id string) (types.Track, error)
	AddTrack(track types.Track) error
	UpdateTrack(track types.Track) error
	DeleteTrack(id string) error

	GetAllAlbums() ([]types.Album, error)
	GetAlbums(userID string) ([]types.Album, error)
	GetAlbum(id string) (types.Album, error)
	AddAlbum(album types.Album) error
	UpdateAlbum(album types.Album) error
	DeleteAlbum(id string) error

	GetAllVideos() ([]types.Video, error)
	GetVideos(userID string) ([]types.Video, error)
	GetVideo(id string) (types.Video, error)
	AddVideo(video types.Video) error
	UpdateVideo(video types.Video) error
	DeleteVideo(id string) error

	GetAllArtists() ([]types.Artist, error)
	GetArtists(userID string) ([]types.Artist, error)
	GetArtist(id string) (types.Artist, error)
	AddArtist(artist types.Artist) error
	UpdateArtist(artist types.Artist) error
	DeleteArtist(id string) error

	GetAllPlaylists() ([]types.Playlist, error)
	GetPlaylists(userID string) ([]types.Playlist, error)
	GetPlaylist(id string) (types.Playlist, error)
	AddPlaylist(playlist types.Playlist) error
	UpdatePlaylist(playlist types.Playlist) error
	DeletePlaylist(id string) error

	GetUsers() ([]types.User, error)
	GetUser(id string) (types.User, error)
	GetUserByUsername(username string) (types.User, error)
	CreateUser(user types.User) error
	UpdateUser(user types.User) error
	UsernameExists(username string) (bool, error)
	EmailExists(email string) (bool, error)
	DeleteUser(id string) error

	BlacklistToken(token string, expiration time.Time) error
	CleanExpiredTokens() error
	IsTokenBlacklisted(token string) (bool, error)
}
var DB Database

type PostgreSQLDatabase

type PostgreSQLDatabase struct {
	// contains filtered or unexported fields
}

func ConnectPostgreSQL

func ConnectPostgreSQL() (*PostgreSQLDatabase, error)

func (*PostgreSQLDatabase) AddAlbum

func (db *PostgreSQLDatabase) AddAlbum(album types.Album) error

func (*PostgreSQLDatabase) AddArtist

func (db *PostgreSQLDatabase) AddArtist(artist types.Artist) error

func (*PostgreSQLDatabase) AddPlaylist

func (db *PostgreSQLDatabase) AddPlaylist(playlist types.Playlist) error

func (*PostgreSQLDatabase) AddTrack

func (db *PostgreSQLDatabase) AddTrack(track types.Track) error

func (*PostgreSQLDatabase) AddVideo

func (db *PostgreSQLDatabase) AddVideo(video types.Video) error

func (*PostgreSQLDatabase) BlacklistToken

func (db *PostgreSQLDatabase) BlacklistToken(token string, expiration time.Time) error

func (*PostgreSQLDatabase) CleanExpiredTokens

func (db *PostgreSQLDatabase) CleanExpiredTokens() error

func (*PostgreSQLDatabase) Close

func (db *PostgreSQLDatabase) Close() error

func (*PostgreSQLDatabase) Connect

func (db *PostgreSQLDatabase) Connect() error

func (*PostgreSQLDatabase) CreateUser

func (db *PostgreSQLDatabase) CreateUser(user types.User) error

func (*PostgreSQLDatabase) DeleteAlbum

func (db *PostgreSQLDatabase) DeleteAlbum(id string) error

func (*PostgreSQLDatabase) DeleteArtist

func (db *PostgreSQLDatabase) DeleteArtist(id string) error

func (*PostgreSQLDatabase) DeletePlaylist

func (db *PostgreSQLDatabase) DeletePlaylist(id string) error

func (*PostgreSQLDatabase) DeleteTrack

func (db *PostgreSQLDatabase) DeleteTrack(id string) error

func (*PostgreSQLDatabase) DeleteUser

func (db *PostgreSQLDatabase) DeleteUser(id string) error

func (*PostgreSQLDatabase) DeleteVideo

func (db *PostgreSQLDatabase) DeleteVideo(id string) error

func (*PostgreSQLDatabase) EmailExists

func (db *PostgreSQLDatabase) EmailExists(email string) (bool, error)

func (*PostgreSQLDatabase) EngineName

func (*PostgreSQLDatabase) EngineName() string

func (*PostgreSQLDatabase) GetAlbum

func (db *PostgreSQLDatabase) GetAlbum(id string) (types.Album, error)

func (*PostgreSQLDatabase) GetAlbums

func (db *PostgreSQLDatabase) GetAlbums(userID string) ([]types.Album, error)

func (*PostgreSQLDatabase) GetAllAlbums

func (db *PostgreSQLDatabase) GetAllAlbums() ([]types.Album, error)

func (*PostgreSQLDatabase) GetAllArtists

func (db *PostgreSQLDatabase) GetAllArtists() ([]types.Artist, error)

func (*PostgreSQLDatabase) GetAllPlaylists

func (db *PostgreSQLDatabase) GetAllPlaylists() ([]types.Playlist, error)

func (*PostgreSQLDatabase) GetAllTracks

func (db *PostgreSQLDatabase) GetAllTracks() ([]types.Track, error)

func (*PostgreSQLDatabase) GetAllVideos

func (db *PostgreSQLDatabase) GetAllVideos() ([]types.Video, error)

func (*PostgreSQLDatabase) GetArtist

func (db *PostgreSQLDatabase) GetArtist(id string) (types.Artist, error)

func (*PostgreSQLDatabase) GetArtists

func (db *PostgreSQLDatabase) GetArtists(userID string) ([]types.Artist, error)

func (*PostgreSQLDatabase) GetPlaylist

func (db *PostgreSQLDatabase) GetPlaylist(id string) (types.Playlist, error)

func (*PostgreSQLDatabase) GetPlaylists

func (db *PostgreSQLDatabase) GetPlaylists(userID string) ([]types.Playlist, error)

func (*PostgreSQLDatabase) GetTrack

func (db *PostgreSQLDatabase) GetTrack(id string) (types.Track, error)

func (*PostgreSQLDatabase) GetTracks

func (db *PostgreSQLDatabase) GetTracks(userID string) ([]types.Track, error)

func (*PostgreSQLDatabase) GetUser

func (db *PostgreSQLDatabase) GetUser(id string) (types.User, error)

func (*PostgreSQLDatabase) GetUserByUsername

func (db *PostgreSQLDatabase) GetUserByUsername(username string) (types.User, error)

func (*PostgreSQLDatabase) GetUsers

func (db *PostgreSQLDatabase) GetUsers() ([]types.User, error)

func (*PostgreSQLDatabase) GetVideo

func (db *PostgreSQLDatabase) GetVideo(id string) (types.Video, error)

func (*PostgreSQLDatabase) GetVideos

func (db *PostgreSQLDatabase) GetVideos(userID string) ([]types.Video, error)

func (*PostgreSQLDatabase) IsTokenBlacklisted

func (db *PostgreSQLDatabase) IsTokenBlacklisted(token string) (bool, error)

func (*PostgreSQLDatabase) MigrateDown

func (db *PostgreSQLDatabase) MigrateDown(steps int) error

func (*PostgreSQLDatabase) MigrateUp

func (db *PostgreSQLDatabase) MigrateUp(steps int) error

func (*PostgreSQLDatabase) UpdateAlbum

func (db *PostgreSQLDatabase) UpdateAlbum(album types.Album) error

func (*PostgreSQLDatabase) UpdateArtist

func (db *PostgreSQLDatabase) UpdateArtist(artist types.Artist) error

func (*PostgreSQLDatabase) UpdatePlaylist

func (db *PostgreSQLDatabase) UpdatePlaylist(playlist types.Playlist) error

func (*PostgreSQLDatabase) UpdateTrack

func (db *PostgreSQLDatabase) UpdateTrack(track types.Track) error

func (*PostgreSQLDatabase) UpdateUser

func (db *PostgreSQLDatabase) UpdateUser(user types.User) error

func (*PostgreSQLDatabase) UpdateVideo

func (db *PostgreSQLDatabase) UpdateVideo(video types.Video) error

func (*PostgreSQLDatabase) UsernameExists

func (db *PostgreSQLDatabase) UsernameExists(username string) (bool, error)

type SQLiteDatabase

type SQLiteDatabase struct {
	// contains filtered or unexported fields
}

func ConnectSQLite

func ConnectSQLite() (*SQLiteDatabase, error)

func (*SQLiteDatabase) AddAlbum

func (db *SQLiteDatabase) AddAlbum(album types.Album) error

func (*SQLiteDatabase) AddArtist

func (db *SQLiteDatabase) AddArtist(artist types.Artist) error

func (*SQLiteDatabase) AddPlaylist

func (db *SQLiteDatabase) AddPlaylist(playlist types.Playlist) error

func (*SQLiteDatabase) AddTrack

func (db *SQLiteDatabase) AddTrack(track types.Track) error

func (*SQLiteDatabase) AddVideo

func (db *SQLiteDatabase) AddVideo(video types.Video) error

func (*SQLiteDatabase) BlacklistToken

func (db *SQLiteDatabase) BlacklistToken(token string, expiration time.Time) error

func (*SQLiteDatabase) CleanExpiredTokens

func (db *SQLiteDatabase) CleanExpiredTokens() error

func (*SQLiteDatabase) Close

func (db *SQLiteDatabase) Close() error

func (*SQLiteDatabase) Connect

func (db *SQLiteDatabase) Connect() error

func (*SQLiteDatabase) CreateUser

func (db *SQLiteDatabase) CreateUser(user types.User) error

func (*SQLiteDatabase) DeleteAlbum

func (db *SQLiteDatabase) DeleteAlbum(id string) error

func (*SQLiteDatabase) DeleteArtist

func (db *SQLiteDatabase) DeleteArtist(id string) error

func (*SQLiteDatabase) DeletePlaylist

func (db *SQLiteDatabase) DeletePlaylist(id string) error

func (*SQLiteDatabase) DeleteTrack

func (db *SQLiteDatabase) DeleteTrack(id string) error

func (*SQLiteDatabase) DeleteUser

func (db *SQLiteDatabase) DeleteUser(id string) error

func (*SQLiteDatabase) DeleteVideo

func (db *SQLiteDatabase) DeleteVideo(id string) error

func (*SQLiteDatabase) EmailExists

func (db *SQLiteDatabase) EmailExists(email string) (bool, error)

func (*SQLiteDatabase) EngineName

func (*SQLiteDatabase) EngineName() string

func (*SQLiteDatabase) GetAlbum

func (db *SQLiteDatabase) GetAlbum(id string) (types.Album, error)

func (*SQLiteDatabase) GetAlbums

func (db *SQLiteDatabase) GetAlbums(userID string) ([]types.Album, error)

func (*SQLiteDatabase) GetAllAlbums

func (db *SQLiteDatabase) GetAllAlbums() ([]types.Album, error)

func (*SQLiteDatabase) GetAllArtists

func (db *SQLiteDatabase) GetAllArtists() ([]types.Artist, error)

func (*SQLiteDatabase) GetAllPlaylists

func (db *SQLiteDatabase) GetAllPlaylists() ([]types.Playlist, error)

func (*SQLiteDatabase) GetAllTracks

func (db *SQLiteDatabase) GetAllTracks() ([]types.Track, error)

func (*SQLiteDatabase) GetAllVideos

func (db *SQLiteDatabase) GetAllVideos() ([]types.Video, error)

func (*SQLiteDatabase) GetArtist

func (db *SQLiteDatabase) GetArtist(id string) (types.Artist, error)

func (*SQLiteDatabase) GetArtists

func (db *SQLiteDatabase) GetArtists(userID string) ([]types.Artist, error)

func (*SQLiteDatabase) GetPlaylist

func (db *SQLiteDatabase) GetPlaylist(id string) (types.Playlist, error)

func (*SQLiteDatabase) GetPlaylists

func (db *SQLiteDatabase) GetPlaylists(userID string) ([]types.Playlist, error)

func (*SQLiteDatabase) GetTrack

func (db *SQLiteDatabase) GetTrack(id string) (types.Track, error)

func (*SQLiteDatabase) GetTracks

func (db *SQLiteDatabase) GetTracks(userID string) ([]types.Track, error)

func (*SQLiteDatabase) GetUser

func (db *SQLiteDatabase) GetUser(id string) (types.User, error)

func (*SQLiteDatabase) GetUserByUsername

func (db *SQLiteDatabase) GetUserByUsername(username string) (types.User, error)

func (*SQLiteDatabase) GetUsers

func (db *SQLiteDatabase) GetUsers() ([]types.User, error)

func (*SQLiteDatabase) GetVideo

func (db *SQLiteDatabase) GetVideo(id string) (types.Video, error)

func (*SQLiteDatabase) GetVideos

func (db *SQLiteDatabase) GetVideos(userID string) ([]types.Video, error)

func (*SQLiteDatabase) IsTokenBlacklisted

func (db *SQLiteDatabase) IsTokenBlacklisted(token string) (bool, error)

func (*SQLiteDatabase) MigrateDown

func (db *SQLiteDatabase) MigrateDown(steps int) error

func (*SQLiteDatabase) MigrateUp

func (db *SQLiteDatabase) MigrateUp(steps int) error

func (*SQLiteDatabase) UpdateAlbum

func (db *SQLiteDatabase) UpdateAlbum(album types.Album) error

func (*SQLiteDatabase) UpdateArtist

func (db *SQLiteDatabase) UpdateArtist(artist types.Artist) error

func (*SQLiteDatabase) UpdatePlaylist

func (db *SQLiteDatabase) UpdatePlaylist(playlist types.Playlist) error

func (*SQLiteDatabase) UpdateTrack

func (db *SQLiteDatabase) UpdateTrack(track types.Track) error

func (*SQLiteDatabase) UpdateUser

func (db *SQLiteDatabase) UpdateUser(user types.User) error

func (*SQLiteDatabase) UpdateVideo

func (db *SQLiteDatabase) UpdateVideo(video types.Video) error

func (*SQLiteDatabase) UsernameExists

func (db *SQLiteDatabase) UsernameExists(username string) (bool, error)

Jump to

Keyboard shortcuts

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