28 lines
521 B
Go
28 lines
521 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"kontor-api-gin/internal/models"
|
|
"log/slog"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ArtistRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewArtistRepository(db *gorm.DB) *ArtistRepository {
|
|
repo := &ArtistRepository{db: db}
|
|
return repo
|
|
}
|
|
|
|
func (repository *ArtistRepository) FindAll(context context.Context) ([]models.Artist, error) {
|
|
var artists []models.Artist
|
|
|
|
result := repository.db.Find(&artists)
|
|
slog.Info("ArtistRepository#FindAll", "count", result.RowsAffected)
|
|
|
|
return artists, nil
|
|
}
|