Documentation
¶
Overview ¶
package psql implements the db.DB interface using psx and a sql generated repository
Index ¶
- Constants
- func ValidateAndNormalizePassword(password string) (string, error)
- func ValidateUsername(username string) error
- type Psql
- func (d *Psql) AddArtistsToAlbum(ctx context.Context, opts db.AddArtistsToAlbumOpts) error
- func (d *Psql) AlbumsWithoutImages(ctx context.Context, from int32) ([]*models.Album, error)
- func (d *Psql) Close(ctx context.Context)
- func (p *Psql) Count(ctx context.Context, query string, args ...any) (count int, err error)
- func (p *Psql) CountAlbums(ctx context.Context, userID int32, period db.Period) (int64, error)
- func (p *Psql) CountArtists(ctx context.Context, userID int32, period db.Period) (int64, error)
- func (p *Psql) CountListens(ctx context.Context, userID int32, period db.Period) (int64, error)
- func (p *Psql) CountTimeListened(ctx context.Context, userID int32, period db.Period) (int64, error)
- func (p *Psql) CountTimeListenedToItem(ctx context.Context, opts db.TimeListenedOpts) (int64, error)
- func (p *Psql) CountTracks(ctx context.Context, userID int32, period db.Period) (int64, error)
- func (d *Psql) CountUsers(ctx context.Context) (int64, error)
- func (d *Psql) DeleteAlbum(ctx context.Context, id int32) error
- func (d *Psql) DeleteAlbumAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) DeleteApiKey(ctx context.Context, id int32, userID int32) error
- func (d *Psql) DeleteArtist(ctx context.Context, id int32) error
- func (d *Psql) DeleteArtistAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) DeleteListen(ctx context.Context, trackId int32, listenedAt time.Time, userId int32) error
- func (d *Psql) DeleteSession(ctx context.Context, sessionId uuid.UUID) error
- func (d *Psql) DeleteTrack(ctx context.Context, id int32) error
- func (d *Psql) DeleteTrackAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) DeleteUser(ctx context.Context, id int32) error
- func (d *Psql) Exec(ctx context.Context, query string, args ...any) error
- func (d *Psql) ExistsListenFuzzy(ctx context.Context, arg repository.ExistsListenFuzzyParams) (bool, error)
- func (d *Psql) GetAlbum(ctx context.Context, opts db.GetAlbumOpts) (*models.Album, error)
- func (d *Psql) GetAlbumByImage(ctx context.Context, image uuid.UUID) (*models.Album, error)
- func (d *Psql) GetAllAlbumAliases(ctx context.Context, id int32) ([]models.Alias, error)
- func (d *Psql) GetAllArtistAliases(ctx context.Context, id int32) ([]models.Alias, error)
- func (d *Psql) GetAllTrackAliases(ctx context.Context, id int32) ([]models.Alias, error)
- func (d *Psql) GetAllUsers(ctx context.Context) ([]*models.User, error)
- func (d *Psql) GetApiKeysByUserID(ctx context.Context, id int32) ([]models.ApiKey, error)
- func (d *Psql) GetArtist(ctx context.Context, opts db.GetArtistOpts) (*models.Artist, error)
- func (d *Psql) GetArtistByImage(ctx context.Context, image uuid.UUID) (*models.Artist, error)
- func (d *Psql) GetArtistsForAlbum(ctx context.Context, id int32) ([]*models.Artist, error)
- func (d *Psql) GetArtistsForTrack(ctx context.Context, id int32) ([]*models.Artist, error)
- func (d *Psql) GetClientSources(ctx context.Context, userID int32) ([]models.ClientSource, error)
- func (d *Psql) GetExportPage(ctx context.Context, opts db.GetExportPageOpts) ([]*db.ExportItem, error)
- func (d *Psql) GetImageSource(ctx context.Context, image uuid.UUID) (string, error)
- func (d *Psql) GetListenActivity(ctx context.Context, opts db.ListenActivityOpts) ([]db.ListenActivityItem, error)
- func (d *Psql) GetListensPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Listen], error)
- func (d *Psql) GetTopAlbumsPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Album], error)
- func (d *Psql) GetTopArtistsPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Artist], error)
- func (d *Psql) GetTopTracksPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Track], error)
- func (d *Psql) GetTrack(ctx context.Context, opts db.GetTrackOpts) (*models.Track, error)
- func (d *Psql) GetUser(ctx context.Context, id int32) (*models.User, error)
- func (d *Psql) GetUserByApiKey(ctx context.Context, key string) (*models.User, error)
- func (d *Psql) GetUserBySession(ctx context.Context, sessionId uuid.UUID) (*models.User, error)
- func (d *Psql) GetUserByUsername(ctx context.Context, username string) (*models.User, error)
- func (s *Psql) GetUserPreferences(ctx context.Context, userId int32) ([]byte, error)
- func (s *Psql) GetUserTheme(ctx context.Context, userId int32) ([]byte, error)
- func (d *Psql) ImageHasAssociation(ctx context.Context, image uuid.UUID) (bool, error)
- func (d *Psql) MergeAlbums(ctx context.Context, fromId, toId int32, replaceImage bool) error
- func (d *Psql) MergeArtists(ctx context.Context, fromId, toId int32, replaceImage bool) error
- func (d *Psql) MergeTracks(ctx context.Context, fromId, toId int32) error
- func (d *Psql) Ping(ctx context.Context) error
- func (p *Psql) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (d *Psql) RefreshSession(ctx context.Context, sessionId uuid.UUID, expiresAt time.Time) error
- func (d *Psql) RowExists(ctx context.Context, query string, args ...any) (bool, error)
- func (d *Psql) SaveAlbum(ctx context.Context, opts db.SaveAlbumOpts) (*models.Album, error)
- func (d *Psql) SaveAlbumAliases(ctx context.Context, id int32, aliases []string, source string) error
- func (d *Psql) SaveApiKey(ctx context.Context, opts db.SaveApiKeyOpts) (*models.ApiKey, error)
- func (d *Psql) SaveArtist(ctx context.Context, opts db.SaveArtistOpts) (*models.Artist, error)
- func (d *Psql) SaveArtistAliases(ctx context.Context, id int32, aliases []string, source string) error
- func (d *Psql) SaveListen(ctx context.Context, opts db.SaveListenOpts) error
- func (d *Psql) SaveSession(ctx context.Context, userID int32, expiresAt time.Time, persistent bool) (*models.Session, error)
- func (d *Psql) SaveTrack(ctx context.Context, opts db.SaveTrackOpts) (*models.Track, error)
- func (d *Psql) SaveTrackAliases(ctx context.Context, id int32, aliases []string, source string) error
- func (d *Psql) SaveUser(ctx context.Context, opts db.SaveUserOpts) (*models.User, error)
- func (s *Psql) SaveUserPreferences(ctx context.Context, userId int32, preferencesData []byte) error
- func (s *Psql) SaveUserTheme(ctx context.Context, userId int32, themeData []byte) error
- func (d *Psql) SearchAlbums(ctx context.Context, q string) ([]*models.Album, error)
- func (d *Psql) SearchArtists(ctx context.Context, q string) ([]*models.Artist, error)
- func (d *Psql) SearchTracks(ctx context.Context, q string) ([]*models.Track, error)
- func (d *Psql) SetPrimaryAlbumAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) SetPrimaryAlbumArtist(ctx context.Context, id int32, artistId int32, value bool) error
- func (d *Psql) SetPrimaryArtistAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) SetPrimaryTrackAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) SetPrimaryTrackArtist(ctx context.Context, id int32, artistId int32, value bool) error
- func (d *Psql) UpdateAlbum(ctx context.Context, opts db.UpdateAlbumOpts) error
- func (d *Psql) UpdateApiKeyLabel(ctx context.Context, opts db.UpdateApiKeyLabelOpts) error
- func (d *Psql) UpdateArtist(ctx context.Context, opts db.UpdateArtistOpts) error
- func (d *Psql) UpdateArtistMetadata(ctx context.Context, opts db.UpdateArtistMetadataParams) error
- func (d *Psql) UpdateReleaseMetadata(ctx context.Context, opts db.UpdateReleaseMetadataParams) error
- func (d *Psql) UpdateTrack(ctx context.Context, opts db.UpdateTrackOpts) error
- func (d *Psql) UpdateTrackMetadata(ctx context.Context, opts db.UpdateTrackMetadataParams) error
- func (d *Psql) UpdateUser(ctx context.Context, opts db.UpdateUserOpts) error
- func (d *Psql) UpsertClientSource(ctx context.Context, userID int32, name, token string) error
Constants ¶
const (
DefaultItemsPerPage = 20
)
Variables ¶
This section is empty.
Functions ¶
func ValidateUsername ¶
Types ¶
type Psql ¶
type Psql struct {
// contains filtered or unexported fields
}
func (*Psql) AddArtistsToAlbum ¶
func (*Psql) AlbumsWithoutImages ¶
func (*Psql) CountAlbums ¶
func (*Psql) CountArtists ¶
func (*Psql) CountListens ¶
func (*Psql) CountTimeListened ¶
func (*Psql) CountTimeListenedToItem ¶
func (*Psql) CountTracks ¶
func (*Psql) DeleteAlbumAlias ¶
func (*Psql) DeleteApiKey ¶
func (*Psql) DeleteArtistAlias ¶
func (*Psql) DeleteListen ¶
func (*Psql) DeleteSession ¶
func (*Psql) DeleteTrackAlias ¶
func (*Psql) DeleteUser ¶ added in v0.1.30
func (*Psql) ExistsListenFuzzy ¶ added in v0.1.30
func (d *Psql) ExistsListenFuzzy(ctx context.Context, arg repository.ExistsListenFuzzyParams) (bool, error)
func (*Psql) GetAlbumByImage ¶ added in v0.1.30
GetAlbumByImage returns album information by image UUID
func (*Psql) GetAllAlbumAliases ¶
func (*Psql) GetAllArtistAliases ¶
func (*Psql) GetAllTrackAliases ¶
func (*Psql) GetAllUsers ¶ added in v0.1.30
func (*Psql) GetApiKeysByUserID ¶
func (*Psql) GetArtist ¶
this function sucks because sqlc keeps making new types for rows that are the same
func (*Psql) GetArtistByImage ¶ added in v0.1.30
GetArtistByImage returns artist information by image UUID
func (*Psql) GetArtistsForAlbum ¶
func (*Psql) GetArtistsForTrack ¶
func (*Psql) GetClientSources ¶ added in v0.1.30
func (*Psql) GetExportPage ¶
func (d *Psql) GetExportPage(ctx context.Context, opts db.GetExportPageOpts) ([]*db.ExportItem, error)
func (*Psql) GetImageSource ¶
func (*Psql) GetListenActivity ¶
func (d *Psql) GetListenActivity(ctx context.Context, opts db.ListenActivityOpts) ([]db.ListenActivityItem, error)
func (*Psql) GetListensPaginated ¶
func (d *Psql) GetListensPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Listen], error)
func (*Psql) GetTopAlbumsPaginated ¶
func (d *Psql) GetTopAlbumsPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Album], error)
func (*Psql) GetTopArtistsPaginated ¶
func (d *Psql) GetTopArtistsPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Artist], error)
func (*Psql) GetTopTracksPaginated ¶
func (d *Psql) GetTopTracksPaginated(ctx context.Context, opts db.GetItemsOpts) (*db.PaginatedResponse[*models.Track], error)
func (*Psql) GetUserByApiKey ¶
Returns nil, nil when no database entries are found
func (*Psql) GetUserBySession ¶
Returns nil, nil when no database entries are found
func (*Psql) GetUserByUsername ¶
Returns nil, nil when no database entries are found
func (*Psql) GetUserPreferences ¶
GetUserPreferences retrieves a user's preferences
func (*Psql) GetUserTheme ¶
GetUserTheme retrieves a user's saved theme
func (*Psql) ImageHasAssociation ¶
func (*Psql) MergeAlbums ¶
func (*Psql) MergeArtists ¶
func (*Psql) MergeTracks ¶
func (*Psql) QueryRow ¶
Exposes p.conn.QueryRow. Only used for testing. Not part of the DB interface this package implements.
func (*Psql) RefreshSession ¶
func (*Psql) RowExists ¶
Not part of the DB interface this package implements. Only used for testing.
func (*Psql) SaveAlbumAliases ¶
func (*Psql) SaveApiKey ¶
func (*Psql) SaveArtist ¶
Equivalent to Psql.SaveArtist, then Psql.SaveMbzAliases
func (*Psql) SaveArtistAliases ¶
func (d *Psql) SaveArtistAliases(ctx context.Context, id int32, aliases []string, source string) error
Inserts all unique aliases into the DB with specified source
func (*Psql) SaveListen ¶
func (*Psql) SaveSession ¶
func (*Psql) SaveTrackAliases ¶
func (*Psql) SaveUserPreferences ¶
SaveUserPreferences saves or updates a user's preferences
func (*Psql) SaveUserTheme ¶
SaveUserTheme saves or updates a user's theme