models

package
v0.0.0-...-633c506 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchSongs

func FetchSongs(db *sqlx.DB, lastValue int, limit int) *[]Song

FetchSongs retrieves all songs from the database.

func GetCassetteMeta

func GetCassetteMeta(cassetteType string) (int, string)

GetCassetteMeta takes cassette type C120, C90, C60. Returns tape single side duration in minutes (int) and type label (string).

func NewDatabase

func NewDatabase(dbConnString string) (*sqlx.DB, error)

NewDatabase creates a new database connection and returns it.

Types

type Cassette

type Cassette struct {
	Type  string       `json:"tape_type"`
	SideA CassetteSide `json:"side_a"`
	SideB CassetteSide `json:"side_b"`
}

Cassette struct for storing songs in cassette format.

func FetchCassette

func FetchCassette(db *sqlx.DB, cassetteType string) *Cassette

FetchCassette query database random songs and create cassette. Args cassetteTypes C120, C90, C60

type CassetteSide

type CassetteSide struct {
	Songs         []Song `json:"songs"`
	DurationLabel string `json:"play_time"`
	Duration      int    `json:"-"`
}

CassetteSide is one side of a cassette.

func (*CassetteSide) AddSong

func (cs *CassetteSide) AddSong(song Song)

AddSong adds a song to a cassette side.

func (*CassetteSide) SetDurationLabel

func (cs *CassetteSide) SetDurationLabel()

SetDurationLabel convert duration to duration label string, ex. 125 == "2:05"

type QueryParams

type QueryParams struct {
	LastValue int `db:"last_value"`
	Limit     int `db:"limit"`
}

QueryParams struct for use with select queries

type Song

type Song struct {
	ID            int    `db:"id" json:"id"`
	Title         string `db:"title" json:"title"`
	Artist        string `db:"artist" json:"artist"`
	Year          int    `db:"year" json:"year"`
	Video         string `db:"video" json:"video"`
	DurationLabel string `db:"duration_label" json:"play_time"`
	Duration      int    `db:"duration" json:"-"`
}

Song is a struct for housing song data.

Jump to

Keyboard shortcuts

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