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, period db.Period) (int64, error)
- func (p *Psql) CountArtists(ctx context.Context, period db.Period) (int64, error)
- func (p *Psql) CountListens(ctx context.Context, period db.Period) (int64, error)
- func (p *Psql) CountTimeListened(ctx context.Context, period db.Period) (int64, error)
- func (p *Psql) CountTimeListenedToItem(ctx context.Context, opts db.TimeListenedOpts) (int64, error)
- func (p *Psql) CountTracks(ctx context.Context, 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) 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) 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) Exec(ctx context.Context, query string, args ...any) error
- func (d *Psql) GetAlbum(ctx context.Context, opts db.GetAlbumOpts) (*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) 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) 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) 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 (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 (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) SetPrimaryArtistAlias(ctx context.Context, id int32, alias string) error
- func (d *Psql) SetPrimaryTrackAlias(ctx context.Context, id int32, alias string) 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) UpdateTrack(ctx context.Context, opts db.UpdateTrackOpts) error
- func (d *Psql) UpdateUser(ctx context.Context, opts db.UpdateUserOpts) error
Constants ¶
View Source
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 ¶ added in v0.0.5
func (*Psql) CountTracks ¶
func (*Psql) DeleteAlbumAlias ¶
func (*Psql) DeleteArtistAlias ¶
func (*Psql) DeleteListen ¶
func (*Psql) DeleteSession ¶
func (*Psql) DeleteTrackAlias ¶
func (*Psql) GetAllAlbumAliases ¶
func (*Psql) GetAllArtistAliases ¶
func (*Psql) GetAllTrackAliases ¶
func (*Psql) GetApiKeysByUserID ¶
func (*Psql) GetArtist ¶
this function sucks because sqlc keeps making new types for rows that are the same
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) 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) SearchAlbums ¶
func (*Psql) SearchArtists ¶
func (*Psql) SearchTracks ¶
func (*Psql) SetPrimaryAlbumAlias ¶
func (*Psql) SetPrimaryArtistAlias ¶
func (*Psql) SetPrimaryTrackAlias ¶
func (*Psql) UpdateAlbum ¶
func (*Psql) UpdateApiKeyLabel ¶
func (*Psql) UpdateArtist ¶
func (*Psql) UpdateTrack ¶
func (*Psql) UpdateUser ¶
Click to show internal directories.
Click to hide internal directories.