db

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TrackCollection = "tracks"

Variables

View Source
var (
	ErrTrackNotFound  = errors.New("track not found")
	ErrTracksNotFound = errors.New("tracks not found")
)

Functions

This section is empty.

Types

type MongoTrackRepository

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

func NewMongoTrackRepository

func NewMongoTrackRepository(db *mongo.Database, maxLyricsImportError int) (MongoTrackRepository, error)

func (MongoTrackRepository) AllTracks

func (t MongoTrackRepository) AllTracks(page, limit int) ([]*Track, int, error)

func (MongoTrackRepository) Count

func (t MongoTrackRepository) Count() (int64, error)

func (MongoTrackRepository) CountWithLyrics

func (t MongoTrackRepository) CountWithLyrics() (int64, error)

func (MongoTrackRepository) CountWithoutLyrics

func (t MongoTrackRepository) CountWithoutLyrics() (int64, error)

func (MongoTrackRepository) FindTrack

func (t MongoTrackRepository) FindTrack(spotifyID string) (*Track, error)

func (MongoTrackRepository) LatestTracks

func (t MongoTrackRepository) LatestTracks(limit int64) ([]*Track, error)

func (MongoTrackRepository) Save

func (t MongoTrackRepository) Save(track *Track) error

func (MongoTrackRepository) Search

func (t MongoTrackRepository) Search(query string, page, limit int, language string) ([]*Track, int, error)

func (MongoTrackRepository) TracksWithLyricsError

func (t MongoTrackRepository) TracksWithLyricsError() ([]*Track, error)

func (MongoTrackRepository) TracksWithoutLyrics

func (t MongoTrackRepository) TracksWithoutLyrics() ([]*Track, error)

func (MongoTrackRepository) TracksWithoutLyricsError

func (t MongoTrackRepository) TracksWithoutLyricsError() ([]*Track, error)

type Repositories

type Repositories struct {
	Tracks TrackRepository
	// contains filtered or unexported fields
}

func New

func New(username, password, databaseName, host string, maxLyricsImportErrorCount int) (*Repositories, error)

type Track

type Track struct {
	ID                     primitive.ObjectID `bson:"_id"`
	SpotifyID              string             `bson:"spotify_id"`
	Artist                 string             `bson:"artist"`
	AlbumName              string             `bson:"album_name"`
	ImageURL               string             `bson:"image_url"`
	PreviewURL             string             `bson:"preview_url"`
	Name                   string             `bson:"name"`
	Lyrics                 string             `bson:"lyrics"`
	LyricsImportErrorCount int                `bson:"lyrics_import_error_count"`
	Loaded                 bool               `bson:"loaded"`
	Language               string             `bson:"language"`
}

func NewTrack

func NewTrack(t spotify.FullTrack) Track

type TrackRepository

type TrackRepository interface {
	FindTrack(string) (*Track, error)
	LatestTracks(limit int64) ([]*Track, error)
	TracksWithoutLyricsError() ([]*Track, error)
	AllTracks(page, limit int) ([]*Track, int, error)
	Search(query string, page, limit int, language string) ([]*Track, int, error)
	Save(track *Track) error

	Count() (int64, error)
	CountWithLyrics() (int64, error)
}

Jump to

Keyboard shortcuts

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