rename book package to media

This commit is contained in:
2022-03-05 10:58:15 -05:00
parent c9b70f02e7
commit 98584bbef6
8 changed files with 41 additions and 38 deletions

View File

@@ -10,7 +10,7 @@ import (
"strings"
"time"
"git.yetaga.in/alazyreader/library/book"
"git.yetaga.in/alazyreader/library/media"
_ "github.com/go-sql-driver/mysql"
)
@@ -142,12 +142,12 @@ func (m *MySQL) RunMigrations(ctx context.Context) (int, int, error) {
return latestMigrationRan, migrationsRun, err
}
func (m *MySQL) GetAllBooks(ctx context.Context) ([]book.Book, error) {
func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) {
if m.connection == nil {
return nil, fmt.Errorf("uninitialized mysql client")
}
books := []book.Book{}
books := []media.Book{}
rows, err := m.connection.QueryContext(ctx, `
SELECT id,
title,
@@ -173,7 +173,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]book.Book, error) {
defer rows.Close()
for rows.Next() {
b := book.Book{}
b := media.Book{}
var authors string
err := rows.Scan(
&b.ID, &b.Title, &authors,
@@ -192,7 +192,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]book.Book, error) {
return books, nil
}
func (m *MySQL) AddBook(ctx context.Context, b *book.Book) error {
func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error {
if m.connection == nil {
return fmt.Errorf("uninitialized mysql client")
}
@@ -232,7 +232,7 @@ func (m *MySQL) AddBook(ctx context.Context, b *book.Book) error {
return nil
}
func (m *MySQL) UpdateBook(ctx context.Context, old, new *book.Book) error {
func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error {
if m.connection == nil {
return fmt.Errorf("uninitialized mysql client")
}