query

package
v0.0.0-...-fbcb358 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package query loads songs and tags from datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlushCache

func FlushCache(ctx context.Context, t cache.Type) error

FlushCache deletes all cached queries and tags from t.

func FlushCacheForUpdate

func FlushCacheForUpdate(ctx context.Context, ut UpdateTypes) error

FlushCacheForUpdate deletes the appropriate cached queries for an update of the supplied types.

func Songs

func Songs(ctx context.Context, query *SongQuery, flags SongsFlags) (results any, numMatched int, err error)

Songs executes the supplied query and returns matching songs. results is a []string if query.OnlyIDs is true or []*common.Song otherwise.

func Tags

func Tags(ctx context.Context, requireCache bool) ([]string, error)

Tags returns the full set of tags present across all songs. It attempts to return cached data before falling back to scanning all songs. If songs are scanned, the resulting tags are cached. If requireCache is true, an error is returned if tags aren't cached.

Types

type SongQuery

type SongQuery struct {
	Artist   string // Song.Artist
	Title    string // Song.Title
	Album    string // Song.Album
	AlbumID  string // Song.AlbumID
	Filename string // song.Filename
	SongID   int64  // song.SongID (0 if unspecified)
	SHA1     string // song.SHA1

	Keywords []string // Song.Keywords

	Rating    int  // Song.Rating (0 if unspecified; use Unrated for 0)
	MinRating int  // Song.Rating (0 if unspecified)
	MaxRating int  // Song.Rating (0 if unspecified)
	Unrated   bool // Song.Rating is 0

	MaxPlays *int64 // Song.NumPlays

	MinFirstStartTime time.Time // Song.FirstStartTime
	MaxLastStartTime  time.Time // Song.LastStartTime

	Track int64 // Song.Track
	Disc  int64 // Song.Disc

	MinDate time.Time // Song.Date
	MaxDate time.Time // Song.Date

	Tags    []string // present in Song.Tags
	NotTags []string // not present in Song.Tags

	Shuffle              bool // randomize results set/order
	OrderByLastStartTime bool // order by Song.LastStartTime
	OnlyIDs              bool // return song IDs instead of songs
	MaxResults           int  // maximum songs to return (0 for default)
}

SongQuery describes a query returning a list of Songs.

type SongsFlags

type SongsFlags uint32

SongsFlags is a bitfield controlling the behavior of the Songs function.

const (
	// CacheOnly indicates that empty results should be returned if the query's results aren't
	// already cached.
	CacheOnly SongsFlags = 1 << iota
	// ForceFallback indicates that the fallback mode that tries to avoid requiring composite
	// indexes should be used instead of the normal mode.
	ForceFallback
	// NoFallback indicates that the fallback mode should never be used.
	NoFallback
)

type UpdateTypes

type UpdateTypes uint32

UpdateTypes is a bitfield describing what was changed by an update. It is used for invalidating cached data.

const (
	MetadataUpdate UpdateTypes = 1 << iota // song metadata
	RatingUpdate
	TagsUpdate
	PlaysUpdate
)

Jump to

Keyboard shortcuts

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