commit 57f4ab3b1b5c83ac7bc33724f378651afb96fad4
parent 2266a3b3232a78f4f7120c54ac02765ae486d2b2
Author: brookjeynes <me@brookjeynes.dev>
Date: Sun, 7 Jun 2026 17:53:52 +1000
refactor: rename Record* structs to New* structs
Signed-off-by: brookjeynes <me@brookjeynes.dev>
Diffstat:
6 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/internal/db/album.go b/internal/db/album.go
@@ -149,7 +149,7 @@ func GetAlbum(e Execer, id domain.AlbumID) (domain.Album, error) {
return album, nil
}
-func InsertAlbum(e Execer, album domain.AlbumRecord) error {
+func InsertAlbum(e Execer, album domain.NewAlbum) error {
result, err := e.Exec(`
insert into albums (
title,
diff --git a/internal/db/song.go b/internal/db/song.go
@@ -213,7 +213,7 @@ func GetSong(e Execer, id domain.SongID) (domain.Song, error) {
return song, nil
}
-func InsertSong(e Execer, song domain.SongRecord) error {
+func InsertSong(e Execer, song domain.NewSong) error {
result, err := e.Exec(`
insert into songs (
title,
diff --git a/internal/domain/album.go b/internal/domain/album.go
@@ -4,22 +4,20 @@ import "time"
type AlbumID int64
-// AlbumRecord is the write model used for inserts.
-type AlbumRecord struct {
+type NewAlbum struct {
ID AlbumID
Title string
LatinName *string
ReleaseDate time.Time
- Artists []AlbumRecordArtist
+ Artists []NewAlbumArtist
}
-type AlbumRecordArtist struct {
+type NewAlbumArtist struct {
ArtistID ArtistID
Role ArtistRole
SortOrder int
}
-// Album is the full read model with all related data embedded.
type Album struct {
ID AlbumID
Title string
diff --git a/internal/domain/song.go b/internal/domain/song.go
@@ -6,30 +6,28 @@ import (
type SongID int64
-// SongRecord is the write model used for inserts.
-type SongRecord struct {
+type NewSong struct {
ID SongID
Title string
LatinTitle *string
Lyrics string
ReleaseDate time.Time
- Artists []SongRecordArtist
- Albums []SongRecordAlbum
+ Artists []NewSongArtist
+ Albums []NewSongAlbum
Genres []Genre
}
-type SongRecordArtist struct {
+type NewSongArtist struct {
ArtistID ArtistID
Role ArtistRole
SortOrder int
}
-type SongRecordAlbum struct {
+type NewSongAlbum struct {
AlbumID AlbumID
TrackNumber *int
}
-// Song is the full read model with all related data embedded.
type Song struct {
ID SongID
Title string
diff --git a/internal/server/new-album.go b/internal/server/new-album.go
@@ -19,8 +19,8 @@ type NewAlbumForm struct {
ReleaseDate string `schema:"release-date"`
}
-func parseNewAlbumForm(form NewAlbumForm) (domain.AlbumRecord, error) {
- var album domain.AlbumRecord
+func parseNewAlbumForm(form NewAlbumForm) (domain.NewAlbum, error) {
+ var album domain.NewAlbum
// title
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Title) {
@@ -32,7 +32,7 @@ func parseNewAlbumForm(form NewAlbumForm) (domain.AlbumRecord, error) {
return album, fmt.Errorf("At least one artist is required")
}
- artists := make([]domain.AlbumRecordArtist, 0, len(form.ArtistID))
+ artists := make([]domain.NewAlbumArtist, 0, len(form.ArtistID))
seenArtists := make(map[int64]struct{}, len(form.ArtistID))
for i, id := range form.ArtistID {
@@ -44,7 +44,7 @@ func parseNewAlbumForm(form NewAlbumForm) (domain.AlbumRecord, error) {
}
seenArtists[int64(id)] = struct{}{}
- artists = append(artists, domain.AlbumRecordArtist{
+ artists = append(artists, domain.NewAlbumArtist{
ArtistID: id,
Role: domain.RolePrimary,
SortOrder: i,
@@ -74,7 +74,7 @@ func parseNewAlbumForm(form NewAlbumForm) (domain.AlbumRecord, error) {
minDate.Format("2006-01-02"), maxDate.Format("2006-01-02"))
}
- album = domain.AlbumRecord{
+ album = domain.NewAlbum{
Title: form.Title,
LatinName: latinTitle,
ReleaseDate: releaseDate,
diff --git a/internal/server/new-song.go b/internal/server/new-song.go
@@ -23,15 +23,15 @@ type NewSongForm struct {
ReleaseDate string `schema:"release-date"`
}
-func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
- var song domain.SongRecord
+func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
+ var song domain.NewSong
// artists
if len(form.ArtistID) == 0 {
return song, fmt.Errorf("At least one artist is required")
}
- artists := make([]domain.SongRecordArtist, 0, len(form.ArtistID)+len(form.FeaturingID))
+ artists := make([]domain.NewSongArtist, 0, len(form.ArtistID)+len(form.FeaturingID))
seenArtists := make(map[int64]struct{}, len(form.ArtistID)+len(form.FeaturingID))
for i, id := range form.ArtistID {
@@ -43,7 +43,7 @@ func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
}
seenArtists[int64(id)] = struct{}{}
- artists = append(artists, domain.SongRecordArtist{
+ artists = append(artists, domain.NewSongArtist{
ArtistID: id,
Role: domain.RolePrimary,
SortOrder: i,
@@ -60,7 +60,7 @@ func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
}
seenArtists[int64(id)] = struct{}{}
- artists = append(artists, domain.SongRecordArtist{
+ artists = append(artists, domain.NewSongArtist{
ArtistID: id,
Role: domain.RoleFeatured,
SortOrder: i,
@@ -98,7 +98,7 @@ func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
}
// albums
- albums := make([]domain.SongRecordAlbum, 0, len(form.AlbumID))
+ albums := make([]domain.NewSongAlbum, 0, len(form.AlbumID))
seenAlbums := make(map[int64]struct{}, len(form.AlbumID))
for _, id := range form.AlbumID {
if id < 0 {
@@ -109,7 +109,7 @@ func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
}
seenAlbums[int64(id)] = struct{}{}
- albums = append(albums, domain.SongRecordAlbum{
+ albums = append(albums, domain.NewSongAlbum{
AlbumID: id,
})
}
@@ -126,7 +126,7 @@ func parseNewSongForm(form NewSongForm) (domain.SongRecord, error) {
minDate.Format("2006-01-02"), maxDate.Format("2006-01-02"))
}
- song = domain.SongRecord{
+ song = domain.NewSong{
Title: form.Title,
LatinTitle: latinTitle,
Lyrics: form.Lyrics,