trackliststore

package
v0.0.0-...-ea92875 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddTracklistParams

type AddTracklistParams struct {
	Name    string     `json:"name"`
	Date    string     `json:"date"`
	URL     string     `json:"url"`
	Artwork string     `json:"artwork"`
	Tracks  [][]string `json:"tracks"`
}

AddTracklistParams are the parameters deserialised from JSON for adding a new tracklist.

func (*AddTracklistParams) ToDatabaseParams

func (t *AddTracklistParams) ToDatabaseParams() db.AddTracklistParams

ToDatabaseParams returns a database params struct for adding a new tracklist.

func (*AddTracklistParams) Validate

func (t *AddTracklistParams) Validate() valid.Error

Validate validate that the data provided is correct for adding a new tracklist.

type Store

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

Store is a store for interacting with tracklists in the data store.

func New

func New(store *datastore.Store) *Store

New returns a new store.

func (*Store) AddTracklist

func (s *Store) AddTracklist(ctx context.Context, model *AddTracklistParams) (*Tracklist, error)

AddTracklist adds the tracklist. If the data is not valid returns an unprocessable entity error.

func (*Store) GetTracklist

func (s *Store) GetTracklist(ctx context.Context, id string) (*Tracklist, error)

GetTracklist returns a tracklist with the given ID. If no tracklist exists return a not found error.

func (*Store) GetTracklists

func (s *Store) GetTracklists(ctx context.Context, page, limit int64) ([]*Tracklist, int64, error)

GetTracklists returns a list of tracklists. The list is paginated based on the page and limit arguments.

func (*Store) GetTracklistsByTrack

func (s *Store) GetTracklistsByTrack(ctx context.Context, id string, page, limit int64) ([]*Tracklist, int64, error)

GetTracklistsByTrack returns a list of tracklists that contain the track witht he given ID. The list is paginated based on the page and limit arguments.

func (*Store) UpdateTracklist

func (s *Store) UpdateTracklist(ctx context.Context, id string, model *UpdateTracklistParams) (*Tracklist, error)

UpdateTracklist uupdates the tracklist with the given ID. If the data is not valid returns an unprocessable entity error. If the tracklist does not exist returns a not found error.

type Tracklist

type Tracklist struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	Date    time.Time `json:"date"`
	URL     string    `json:"url"`
	Artwork string    `json:"artwork"`

	Created time.Time `json:"-"`
	Updated time.Time `json:"-"`

	Tracks     []*trackstore.Track `json:"tracks,omitempty"`
	TrackCount int                 `json:"trackCount"`
}

Tracklist is the model used for serialising a tracklist to JSON.

type UpdateTracklistParams

type UpdateTracklistParams struct {
	Name string `json:"name"`
	Date string `json:"date"`
	URL  string `json:"url"`
}

UpdateTracklistParams are the parameters deserialised from JSON for updating an existing tracklist.

func (*UpdateTracklistParams) ToDatabaseParams

func (t *UpdateTracklistParams) ToDatabaseParams(id string) db.UpdateTracklistParams

ToDatabaseParams returns a database params struct for updating an existing tracklist.

func (*UpdateTracklistParams) Validate

func (t *UpdateTracklistParams) Validate() valid.Error

Validate validates that the data provided is correct for updating an existing tracklist.

Jump to

Keyboard shortcuts

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