Documentation
¶
Overview ¶
Package edb contains the Elakshi database models.
Index ¶
- Variables
- func AutoMigrate(db *gorm.DB) error
- func DecodeEID(eid string) (uint64, error)
- func EncodeEID(id uint64) string
- func GetAlbumLengthMS(db *gorm.DB, albumID uint64) (uint64, error)
- func GetModelByExternalRef(db *gorm.DB, service, identifier string, out interface{}) (bool, error)
- func GetModelByExternalRefs(db *gorm.DB, out interface{}, refs []ExternalRef) (bool, error)
- func JoinModelExternalRef(model interface{}) func(*gorm.DB) *gorm.DB
- type Album
- type Artist
- type AudioSource
- type DBModel
- type ElakshiURN
- type ExternalRef
- type Genre
- type Image
- type Lyrics
- type Playlist
- type PlaylistTrack
- type RadioStation
- type Track
- type TrackSource
- type URNPartsProvider
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidURN = errors.New("invalid elakshi urn") ErrInvalidNID = errors.New("urn has invalid nid") )
var ( // ErrEIDInvalid is the error returned if an invalid eid is being parsed. ErrEIDInvalid = errors.New("eid invalid") )
Functions ¶
func AutoMigrate ¶
func DecodeEID ¶
DecodeEID converts the encoded id into its integer representation. Returns ErrEIDInvalid if the eid is invalid.
func GetAlbumLengthMS ¶
GetAlbumLengthMS returns the total length of all tracks in an album.
func GetModelByExternalRef ¶
GetModelByExternalRef searches a model out based on an external reference.
func GetModelByExternalRefs ¶
func GetModelByExternalRefs(db *gorm.DB, out interface{}, refs []ExternalRef) (bool, error)
GetModelByExternalRefs returns the first model found using one of the references.
func JoinModelExternalRef ¶
JoinModelExternalRef joins the ExternalRef rows under the alias "er". The join table is also available under the alias "jt". Assumes that the model stores the external references in an "ExternalReferences" field.
Types ¶
type Album ¶
type Artist ¶
type AudioSource ¶
type AudioSource struct { DBModel Service string `gorm:"UNIQUE_INDEX:uix_uri_type;NOT NULL"` URI string `gorm:"UNIQUE_INDEX:uix_uri_type;NOT NULL"` TrackSources []TrackSource }
type ElakshiURN ¶
ElakshiURN represents a URN for an Elakshi entity.
func NewElakshiURN ¶
func NewElakshiURN(namespace, eid string) ElakshiURN
NewElakshiURN builds an ElakshiURN from the namespace and eid.
func ParseURN ¶
func ParseURN(u string) (ElakshiURN, error)
ParseURN parses a urn string into an ElakshiURN string. Note that it only accepts Elakshi urns.
func URNFromParts ¶
func URNFromParts(parts URNPartsProvider) ElakshiURN
URNFromParts creates an ElakshiURN from a URNPartsProvider.
func (ElakshiURN) DecodeEID ¶
func (u ElakshiURN) DecodeEID() (uint64, error)
func (ElakshiURN) String ¶
func (u ElakshiURN) String() string
func (ElakshiURN) URN ¶
func (u ElakshiURN) URN() string
type ExternalRef ¶
type ExternalRef struct { ID uint64 Service string `gorm:"UNIQUE_INDEX:uix_reference_id"` Identifier string `gorm:"UNIQUE_INDEX:uix_reference_id"` }
func NewExternalRef ¶
func NewExternalRef(service, id string) ExternalRef
type Genre ¶
type Genre struct { DBModel Name string `gorm:"UNIQUE_INDEX:uix_genre"` ParentID *uint64 `gorm:"UNIQUE_INDEX:uix_genre"` Parent *Genre }
func GetParentGenres ¶
GetParentGenres returns a slice containing the upper hierarchy of a genre. The order is lowest-first and includes the genre itself as the first entry.
func GetSubGenres ¶
GetSubGenres returns a slice containing the lower hierarchy of a genre. The order is lowest-first and includes the genre itself as the first entry.
type Lyrics ¶
func GetTrackLyrics ¶
GetTrackLyrics retrieves the lyrics for a given track.
type Playlist ¶
type PlaylistTrack ¶
type RadioStation ¶
type RadioStation struct { DBModel Name string ImageID uint64 `gorm:"NOT NULL"` Image Image Genres []Genre `gorm:"MANY2MANY:radio_genres"` }
func (RadioStation) Namespace ¶
func (r RadioStation) Namespace() string
type Track ¶
type Track struct { DBModel Name string LengthMS uint32 `gorm:"type:integer"` ArtistID *uint64 Artist Artist AdditionalArtists []Artist `gorm:"MANY2MANY:track_additional_artists"` AlbumID *uint64 Album Album Images []Image `gorm:"MANY2MANY:track_images"` ReleaseDate *time.Time Genres []Genre `gorm:"MANY2MANY:track_genres"` ExternalReferences []ExternalRef `gorm:"MANY2MANY:track_references"` }
func (Track) AllArtists ¶
AllArtists a slice containing all artists.
type TrackSource ¶
type TrackSource struct { DBModel AudioSourceID uint64 `gorm:"NOT NULL"` AudioSource *AudioSource TrackID uint64 `gorm:"NOT NULL"` Track Track StartOffsetMS uint32 `gorm:"type:integer"` EndOffsetMS uint32 `gorm:"type:integer"` }
func GetTrackSource ¶
func GetTrackSource(db *gorm.DB, trackID uint64) (TrackSource, error)
func (TrackSource) Length ¶
func (ts TrackSource) Length() time.Duration
Length returns the length of the track as a duration.