Documentation ¶
Index ¶
- func ConnectToDB(dbPath string) (*sql.DB, error)
- func Init(dbPath string) *sql.DB
- type Book
- type BookShelf
- func (b *BookShelf) AddBook(decoder *json.Decoder) (*Book, error)
- func (b *BookShelf) DeleteBook(bookID int) (sql.Result, error)
- func (b *BookShelf) GetBook(bookID int) (*Book, error)
- func (b *BookShelf) GetBooks() ([]Book, error)
- func (b *BookShelf) UpdateBook(decoder *json.Decoder, bookID int) (*Book, error)
- type BookStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Book ¶
type Book struct { // all field tags must be exported through capitalization // if they are to be used in the JSON encodings ID int `json:"id,omitempty"` // `omitempty` excludes the field from the JSON encoding if its empty ISBN int `json:"isbn,omitempty"` Title string `json:"title"` Author string `json:"author"` Genres string `json:"genres"` Year int `json:"year,omitempty"` }
Book contains the properties that the books stored in the DB have.
type BookShelf ¶
BookShelf is the struct that implements BookStore here. The 'Book' struct is used to store data when performing operations on the BookShelf. So, a BookShelf stores many books and acts as a small-scale representation of what a BookStore would be.
func (*BookShelf) DeleteBook ¶
DeleteBook receives the book to deleted as POST body and remvoes it from the database.
Click to show internal directories.
Click to hide internal directories.