Convert Id to ID

This commit is contained in:
Las Zenow 2016-07-30 07:59:30 -04:00
parent f12114c296
commit 52b9882be9
17 changed files with 76 additions and 78 deletions

View file

@ -5,8 +5,9 @@ import (
"time"
)
// Book metadata
type Book struct {
Id string
ID string
Title string
Authors []string `sql:"authors" pg:",array"`
Contributor string
@ -42,6 +43,8 @@ func (db *pgDB) GetBooks(query string, length int, start int) (books []Book, num
// TODO: func (db *pgDB) GetBooksIter() Iter {
// GetNewBooks returns a list of books in the incoming queue and the number of books
// in the queue
func (db *pgDB) GetNewBooks(query string, length int, start int) (books []Book, num int, err error) {
return db.getBooks(false, query, length, start)
}
@ -81,7 +84,8 @@ func (db *pgDB) getBooks(active bool, query string, length int, start int) (book
return books, num, err
}
func (db *pgDB) GetBookId(id string) (Book, error) {
// GetBookID returns a the book with the specified id
func (db *pgDB) GetBookID(id string) (Book, error) {
var book Book
err := db.sql.Model(&book).
Where("id = ?", id).
@ -89,6 +93,7 @@ func (db *pgDB) GetBookId(id string) (Book, error) {
return book, err
}
// DeleteBook removes the book with id from the database
func (db *pgDB) DeleteBook(id string) error {
_, err := db.sql.Model(&Book{}).
Where("id = ?", id).
@ -96,6 +101,7 @@ func (db *pgDB) DeleteBook(id string) error {
return err
}
// UpdateBook metadata
func (db *pgDB) UpdateBook(id string, data map[string]interface{}) error {
setCondition := ""
params := []interface{}{}
@ -125,11 +131,7 @@ func (db *pgDB) UpdateBook(id string, data map[string]interface{}) error {
return err
}
func (db *pgDB) FlagBadQuality(id string, user string) error {
// TODO: delete me
return nil
}
// ActiveBook activates the book
func (db *pgDB) ActiveBook(id string) error {
uploadDate := time.Now()
_, err := db.sql.Model(&Book{}).
@ -139,6 +141,7 @@ func (db *pgDB) ActiveBook(id string) error {
return err
}
// IsBookActive checks if the book is active
func (db *pgDB) IsBookActive(id string) bool {
var active []bool
err := db.sql.Model(&Book{}).