dbManager

package
v0.0.0-...-ea888db Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

The DAO of the database

Index

Constants

View Source
const (
	Insert = "INSERT INTO %s (%s) VALUES (%s);"
	Select = "SELECT %s FROM %s WHERE %s;"
	Update = "UPDATE %s SET %s WHERE %s;"
)

The two queries to be used, ready for formating.

View Source
const (
	Types table = iota
	Performers
	Persons
	Groups
	Albums
	Rolas
	InGroup
)

Enumeration of tables

Variables

This section is empty.

Functions

This section is empty.

Types

type All

type All struct{}

All gets everything

func (*All) GetStringQuery

func (a *All) GetStringQuery() string

GetStringQuery gets a string representation of the query

type Assign

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

Assign is a direct assignment

func NewAssign

func NewAssign(f, v string) *Assign

NewAssign gets a new assign query

func (*Assign) GetStringQuery

func (a *Assign) GetStringQuery() string

GetStringQuery gets a string representation of the query

type Condition

type Condition interface {
	GetStringQuery() string
}

Condition is an interface to simulat SQL conditions

type DAO

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

DAO

func NewDAO

func NewDAO(path string) *DAO

NewDAO given the location of the database file

func (*DAO) GetAlbumID

func (d *DAO) GetAlbumID(path string) (int, error)

GetAlbumID given its path in the file system

func (*DAO) GetPerformerID

func (d *DAO) GetPerformerID(name string) (int, error)

GetPerformerID given its name

func (*DAO) GetPerformerType

func (d *DAO) GetPerformerType(idPerf string) (string, error)

GetPerformerType given its id. It can be unknown, a group or a person

func (*DAO) Init

func (d *DAO) Init(templatePath string) error

Init creates the database file from a sql template

func (*DAO) InsertAlbum

func (d *DAO) InsertAlbum(path, name, year string) (sql.Result, error)

InsertAlbum given a name and a year

func (*DAO) InsertGroup

func (d *DAO) InsertGroup(name, startDate, endDate string) (sql.Result, error)

InsertGroup given the full group data

func (*DAO) InsertInGroup

func (d *DAO) InsertInGroup(personID, groupID string) (sql.Result, error)

InsertInGroup gives the relation of member of a group

func (*DAO) InsertPerformer

func (d *DAO) InsertPerformer(name string) (sql.Result, error)

InsertPerformer given its name

func (*DAO) InsertPerson

func (d *DAO) InsertPerson(stageName, realName, birthDate, deathDate string) (sql.Result, error)

InsertPerson given the full person data

func (*DAO) InsertSong

func (d *DAO) InsertSong(s *Song) (sql.Result, error)

InsertSong inserts a song

func (*DAO) NewSong

func (d *DAO) NewSong(path string, tags *id3v2.Tag) *Song

NewSong given its path and its id3v tags

func (*DAO) SearchSelect

func (d *DAO) SearchSelect(title, artist, album string) []int

SearchSelect gives a slice of songs id given a title, an album and an artist to be contained in each of those fields.

func (*DAO) SelectSongs

func (d *DAO) SelectSongs(songConds []Condition) ([]*Song, error)

SelectSongs gets a slice of songs from the database given several conditions.

func (*DAO) SelectSongsFromAlbum

func (d *DAO) SelectSongsFromAlbum(al string) []int

SelectSongsFromAlbum gets a slice of song id give a string to be contained in the album

func (*DAO) SelectSongsFromArtist

func (d *DAO) SelectSongsFromArtist(ar string) []int

SelectSongsFromArtist gets a slice of song id give a string to be contained in the artist

func (*DAO) SelectSongsFromTitle

func (d *DAO) SelectSongsFromTitle(title string) []int

SelectSongsFromTitle gets a slice of song id give a string to be contained in the title

func (*DAO) UpdateAlbum

func (d *DAO) UpdateAlbum(albumID string, newValues []*Assign) (sql.Result, error)

UpdateAlbum given some new values

func (*DAO) UpdateSong

func (d *DAO) UpdateSong(s *Song, newValues []*Assign) (sql.Result, error)

UpdateSong updated the values of the song in the database

type Like

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

Like is a LIKE sql condition

func NewLike

func NewLike(f, v string) *Like

NewLike gets a new LIKE struct

func (*Like) GetStringQuery

func (l *Like) GetStringQuery() string

GetStringQuery get the LIKE sql condition

type Song

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

Song emulates a song in the database

func (*Song) GetAlbum

func (s *Song) GetAlbum() string

GetAlbum gets the album

func (*Song) GetAlbumID

func (s *Song) GetAlbumID() int

GetAlbumID gets the id

func (*Song) GetArtist

func (s *Song) GetArtist() string

GetArtist gets the artist

func (*Song) GetArtistID

func (s *Song) GetArtistID() int

GetArtistID gets the id

func (*Song) GetGenre

func (s *Song) GetGenre() string

GetGenre gets the genre

func (*Song) GetID

func (s *Song) GetID() int

GetID gets the id

func (*Song) GetPath

func (s *Song) GetPath() string

GetPath gets the path

func (*Song) GetTags

func (s *Song) GetTags() *id3v2.Tag

GetTa gets the raw id3v tags

func (*Song) GetTitle

func (s *Song) GetTitle() string

GetTitle gets the title

func (*Song) GetYear

func (s *Song) GetYear() string

GetYear gets the year

func (*Song) SetAlbum

func (s *Song) SetAlbum(a string)

SetAlbum sets the album

func (*Song) SetArtist

func (s *Song) SetArtist(a string)

SetArtist sets the artist

func (*Song) SetGenre

func (s *Song) SetGenre(g string)

SetGenre sets the genre

func (*Song) SetTags

func (s *Song) SetTags(tags *id3v2.Tag)

SetTags sets the tags

func (*Song) SetTitle

func (s *Song) SetTitle(t string)

SetTitle sets the title

func (*Song) SetYear

func (s *Song) SetYear(y string)

SetYear set the year

Jump to

Keyboard shortcuts

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