Library/models/author.go

33 lines
733 B
Go
Raw Normal View History

package models
type Author struct {
2017-11-07 15:35:10 +00:00
ID int64 `xorm:"int(11) autoincr not null unique pk"`
Forename string `xorm:"varchar(250)"`
Lastname string `xorm:"varchar(250) not null"`
2017-11-07 15:35:10 +00:00
Created int64 `xorm:"created"`
Updated int64 `xorm:"updated"`
}
func (Author) TableName() string {
return "authors"
}
type AuthorBook struct {
2017-11-07 15:35:10 +00:00
ID int64 `xorm:"int(11) autoincr not null unique pk"`
AuthorID int64 `xorm:"int(11)"`
2017-11-07 15:35:10 +00:00
BookID int64 `xorm:"int(11)"`
Created int64 `xorm:"created"`
Updated int64 `xorm:"updated"`
}
func (AuthorBook) TableName() string {
return "authors_books"
}
func GetAuthorByID(id int64) (author Author, exists bool, err error) {
has, err := x.Id(id).Get(&author)
return author, has, err
2017-11-07 15:35:10 +00:00
}