This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user