Struct definition

Signed-off-by: kolaente <konrad@kola-entertainments.de>
This commit is contained in:
konrad 2017-10-09 18:29:46 +02:00 committed by kolaente
parent d26df6c160
commit d29b619418
2 changed files with 15 additions and 14 deletions

15
models/book.go Normal file
View File

@ -0,0 +1,15 @@
package models
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"
}

View File

@ -2,20 +2,6 @@ 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 error) {
err = x.Find(&books)