28 lines
500 B
Go
28 lines
500 B
Go
|
package models
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type Book struct {
|
||
|
ID int64 `xorm:"int(11) autoincr not null unique pk"`
|
||
|
Title string `xorm:"varchar(250) not null"`
|
||
|
Isbn string `xorm:"varchar(30)"`
|
||
|
Year int64 `xorm:"int(11)"`
|
||
|
Price float64 `xorm:"double"`
|
||
|
Status int64 `xorm:"int(11)"`
|
||
|
Publisher int64 `xorm:"int(11)"`
|
||
|
}
|
||
|
|
||
|
func (Book) TableName() string{
|
||
|
return "books"
|
||
|
}
|
||
|
|
||
|
func ListBooks() (books []*Book) {
|
||
|
|
||
|
err := x.Find(&books)
|
||
|
if err != nil {
|
||
|
fmt.Println("Error getting Books", err)
|
||
|
}
|
||
|
|
||
|
return books
|
||
|
}
|