database

package
v0.0.0-...-6034ff4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artist

type Artist struct {
	ID     int    `sql:"index"`
	Name   string `sql:"unique_index"`
	Tracks []Track
}

Artist struct

type DB

type DB struct {
	gorm.DB
}

DB struct

func NewDB

func NewDB() (*DB, error)

NewDB establishes a connection with the database and sets the DB struct

func (*DB) AddArtist

func (db *DB) AddArtist(name string) bool

AddArtist Inserts a new artist into the database

func (*DB) AddTrack

func (db *DB) AddTrack(artist, album, title string, date time.Time) bool

AddTrack inserts a track into the database

func (*DB) FindLastListen

func (db *DB) FindLastListen() (int64, error)

func (*DB) NewRec

func (db *DB) NewRec(table, field, data string) bool

NewRec returns a bool depending on whether or not it could find a record

func (*DB) RecentTracks

func (db *DB) RecentTracks() (s string, err error)

RecentTracks returns a string of recently played tracks.

func (*DB) Scrobbles

func (db *DB) Scrobbles() (s string)

Scrobbles returns a string with your userrname, number of scrobbles, artists, and your first play date.

func (*DB) TopAlbums

func (db *DB) TopAlbums() (s string, err error)

TopAlbums returns a string of your top played albums.

func (*DB) TopArtists

func (db *DB) TopArtists() (s string, err error)

TopArtists returns a string of your top played artists

func (*DB) TopSongs

func (db *DB) TopSongs() (s string, err error)

TopSongs returns a string of your top played songs.

type Datastore

type Datastore interface {
	AddArtist(name string) bool
	AddTrack(artist, album, title string, date time.Time) bool
	FindLastListen() (int64, error)
	RecentTracks() (string, error)
	Scrobbles() string
	TopArtists() (string, error)
	TopAlbums() (string, error)
	TopSongs() (string, error)
}

Datastore interface

type Track

type Track struct {
	ID       int `sql:"index"`
	ArtistID int
	Title    string
	Artist   string
	Album    string
	Date     time.Time `sql:"unique_index"`
}

Track struct

Jump to

Keyboard shortcuts

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