database

package
v0.0.0-...-9b17934 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrConflict = errors.New("conflict")
)

Functions

This section is empty.

Types

type Database

type Database interface {
	BeginTx() (Transaction, error)
	Close() error

	AddSession(session Session) error
	DeleteSession(uid string) error
	GetSessionByUserId(userId string) (Session, error)

	AddRemyx(rmx Remyx) error
	UpdateRemyx(rmx Remyx) error
	DeleteRemyx(uid string) error
	GetRemyx(uid string) (Remyx, error)
	ListRemyxes(userId string) ([]RemyxWithCount, error)

	AddSourcePlaylist(pl RemyxPlaylist) error
	DeleteSourcePlaylist(remyxUid, userUid, playlistUid string) error
	GetSourcePlaylists(remyxUid string) ([]RemyxPlaylist, error)

	AddTargetPlaylist(pl RemyxPlaylist) error
	DeleteTargetPlaylist(remyxUid, userUid string) error
	GetTargetPlaylists(remyxUid string) ([]RemyxPlaylist, error)
}

type Entity

type Entity struct {
	Uid       string    `json:"uid"`
	CreatedAt time.Time `json:"created_at"`
}

func NewEntity

func NewEntity() Entity

type PostgresDriver

type PostgresDriver struct {
	*SQLDriver
	// contains filtered or unexported fields
}

func NewPostgresDriver

func NewPostgresDriver(dsn string) (*PostgresDriver, error)

func (*PostgresDriver) BeginTx

func (t *PostgresDriver) BeginTx() (Transaction, error)

func (*PostgresDriver) Close

func (t *PostgresDriver) Close() error

type Remyx

type Remyx struct {
	Entity

	CreatorUid string  `json:"creator_uid"`
	Head       int     `json:"head"`
	Name       *string `json:"name"`
}

type RemyxPlaylist

type RemyxPlaylist struct {
	RemyxUid    string     `json:"remyx_uid"`
	PlaylistUid spotify.ID `json:"playlist_uid"`
	UserUid     string     `json:"user_uid"`
}

type RemyxWithCount

type RemyxWithCount struct {
	Remyx

	PlaylistCount int `json:"playlist_count"`
}

type SQLDriver

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

func (*SQLDriver) AddRemyx

func (t *SQLDriver) AddRemyx(rmx Remyx) error

func (*SQLDriver) AddSession

func (t *SQLDriver) AddSession(session Session) error

func (*SQLDriver) AddSourcePlaylist

func (t *SQLDriver) AddSourcePlaylist(pl RemyxPlaylist) error

func (*SQLDriver) AddTargetPlaylist

func (t *SQLDriver) AddTargetPlaylist(pl RemyxPlaylist) error

func (*SQLDriver) BeginTx

func (t *SQLDriver) BeginTx() (Transaction, error)

func (*SQLDriver) Close

func (t *SQLDriver) Close() error

func (*SQLDriver) DeleteRemyx

func (t *SQLDriver) DeleteRemyx(uid string) error

func (*SQLDriver) DeleteSession

func (t *SQLDriver) DeleteSession(uid string) error

func (*SQLDriver) DeleteSourcePlaylist

func (t *SQLDriver) DeleteSourcePlaylist(remyxUid, userUid, playlistUid string) error

func (*SQLDriver) DeleteTargetPlaylist

func (t *SQLDriver) DeleteTargetPlaylist(remyxUid, userUid string) error

func (*SQLDriver) GetRemyx

func (t *SQLDriver) GetRemyx(uid string) (Remyx, error)

func (*SQLDriver) GetSessionByUserId

func (t *SQLDriver) GetSessionByUserId(userId string) (Session, error)

func (*SQLDriver) GetSourcePlaylists

func (t *SQLDriver) GetSourcePlaylists(remyxUid string) ([]RemyxPlaylist, error)

func (*SQLDriver) GetTargetPlaylists

func (t *SQLDriver) GetTargetPlaylists(remyxUid string) ([]RemyxPlaylist, error)

func (*SQLDriver) ListRemyxes

func (t *SQLDriver) ListRemyxes(userId string) ([]RemyxWithCount, error)

func (*SQLDriver) UpdateRemyx

func (t *SQLDriver) UpdateRemyx(rmx Remyx) error

type Session

type Session struct {
	Entity

	UserId       string `json:"user_uid"`
	RefreshToken string `json:"refresh_token"`
}

type TX

type TX struct {
	sync.Mutex

	*SQLDriver
	// contains filtered or unexported fields
}

func (*TX) Close

func (t *TX) Close() error

func (*TX) Commit

func (t *TX) Commit() error

func (*TX) Rollback

func (t *TX) Rollback() error

type Transaction

type Transaction interface {
	Database
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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