quintodrome/model/get_entity.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
478 B
Go
Raw Normal View History

package model
2020-10-20 09:38:44 -08:00
import (
"context"
)
// TODO: Should the type be encoded in the ID?
2026-02-08 05:57:30 -09:00
func GetEntityByID(ctx context.Context, ds DataStore, id string) (any, error) {
2020-10-20 09:38:44 -08:00
ar, err := ds.Artist(ctx).Get(id)
if err == nil {
return ar, nil
}
al, err := ds.Album(ctx).Get(id)
if err == nil {
return al, nil
}
pls, err := ds.Playlist(ctx).Get(id)
if err == nil {
return pls, nil
}
mf, err := ds.MediaFile(ctx).Get(id)
if err == nil {
return mf, nil
}
return nil, err
}