Added lookup one single book
Signed-off-by: kolaente <konrad@kola-entertainments.de>
This commit is contained in:
parent
167ba086d7
commit
fed91b9e8a
|
@ -22,9 +22,9 @@ func (Book) TableName() string{
|
|||
}
|
||||
|
||||
func GetBookById(ID string) (book Book, err error) {
|
||||
// Get the Book
|
||||
_, err = x.ID(ID).Get(&book)
|
||||
|
||||
|
||||
// Get publisher
|
||||
publisher := Publisher{ID: book.Publisher}
|
||||
_, err = x.Get(&publisher)
|
||||
|
|
|
@ -2,9 +2,16 @@ package models
|
|||
|
||||
import "fmt"
|
||||
|
||||
type BookPublisher struct {
|
||||
Book `xorm:"extends"`
|
||||
Publisher `xorm:"extends"`
|
||||
}
|
||||
|
||||
func ListBooks() (books []*Book, err error) {
|
||||
|
||||
err = x.Find(&books)
|
||||
err = x.Table("books").
|
||||
//Join("INNER", "publishers", "books.publisher = publishers.id").
|
||||
Find(&books)
|
||||
if err != nil {
|
||||
fmt.Println("Error getting Books", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue