add 'childrens' as a field on books
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-10-08 15:05:15 -04:00
parent 1069dadd10
commit 77ddc7ec8e
5 changed files with 34 additions and 12 deletions

View File

@@ -155,7 +155,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) {
allBooksQuery := fmt.Sprintf(`SELECT
id, title, authors, sortauthor, isbn10, isbn13, format,
genre, publisher, series, volume, year, signed,
description, notes, coverurl
description, notes, coverurl, childrens
FROM %s`, m.tableName)
books := []media.Book{}
@@ -174,7 +174,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) {
&b.Format, &b.Genre, &b.Publisher,
&b.Series, &b.Volume, &b.Year,
&b.Signed, &b.Description, &b.Notes,
&b.CoverURL)
&b.CoverURL, &b.Childrens)
if err != nil {
return nil, err
}
@@ -193,9 +193,9 @@ func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error {
res, err := m.connection.ExecContext(ctx, `
INSERT INTO `+m.tableName+`
(title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, description, notes, coverurl)
(title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, description, notes, coverurl, childrens)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
b.Title,
strings.Join(b.Authors, ";"),
b.SortAuthor,
@@ -211,6 +211,7 @@ func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error {
b.Description,
b.Notes,
b.CoverURL,
b.Childrens,
)
if err != nil {
return err
@@ -251,6 +252,7 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error {
description=?
notes=?
coverurl=?
childrens=?
WHERE id=?`,
new.Title,
strings.Join(new.Authors, ";"),
@@ -267,6 +269,7 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error {
new.Description,
new.Notes,
new.CoverURL,
new.Childrens,
old.ID)
if err != nil {
return err