models

package
v0.0.0-...-4231655 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VolumePaper   = "paperbook"
	VolumeElectro = "ebook"
	VolumeAudio   = "audiobook"
)

List of possible "volumes" (book types)

Variables

View Source
var BookBrokenTable = &bookBrokenTableType{
	s: parse.StructInfo{Type: "BookBroken", SQLSchema: "", SQLName: "books_broken", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "URL", Type: "string", Column: "url"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0},
	z: new(BookBroken).Values(),
}

BookBrokenTable represents books_broken view or table in SQL database.

View Source
var BookTable = &bookTableType{
	s: parse.StructInfo{Type: "Book", SQLSchema: "", SQLName: "books", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "MIFID", Type: "*int32", Column: "mif_id"}, {Name: "CategoryID", Type: "*int32", Column: "category_id"}, {Name: "Title", Type: "*string", Column: "title"}, {Name: "ISBN", Type: "*string", Column: "isbn"}, {Name: "Authors", Type: "*string", Column: "authors"}, {Name: "URL", Type: "string", Column: "url"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}, {Name: "IsVisible", Type: "bool", Column: "is_visible"}}, PKFieldIndex: 0},
	z: new(Book).Values(),
}

BookTable represents books view or table in SQL database.

View Source
var CategoryTable = &categoryTableType{
	s: parse.StructInfo{Type: "Category", SQLSchema: "", SQLName: "categories", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "Title", Type: "string", Column: "title"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0},
	z: new(Category).Values(),
}

CategoryTable represents categories view or table in SQL database.

View Source
var LibraryTable = &libraryTableType{
	s: parse.StructInfo{Type: "Library", SQLSchema: "", SQLName: "library", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "UserID", Type: "int32", Column: "user_id"}, {Name: "VolumeID", Type: "int32", Column: "volume_id"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0},
	z: new(Library).Values(),
}

LibraryTable represents library view or table in SQL database.

View Source
var UserTable = &userTableType{
	s: parse.StructInfo{Type: "User", SQLSchema: "", SQLName: "users", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "Email", Type: "string", Column: "email"}, {Name: "Token", Type: "string", Column: "token"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0},
	z: new(User).Values(),
}

UserTable represents users view or table in SQL database.

View Source
var VolumeTable = &volumeTableType{
	s: parse.StructInfo{Type: "Volume", SQLSchema: "", SQLName: "volumes", Fields: []parse.FieldInfo{{Name: "ID", Type: "int32", Column: "id"}, {Name: "BookID", Type: "int32", Column: "book_id"}, {Name: "Type", Type: "string", Column: "type"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0},
	z: new(Volume).Values(),
}

VolumeTable represents volumes view or table in SQL database.

Functions

func CheckVolume

func CheckVolume(volume string) bool

CheckVolume checks if the given volume is supported

func GetVolumes

func GetVolumes() []string

GetVolumes returns list of possible "volumes" (book types)

Types

type Book

type Book struct {
	ID         int32     `reform:"id,pk" json:"id"`
	MIFID      *int32    `reform:"mif_id" json:"mif_id"`
	CategoryID *int32    `reform:"category_id" json:"category_id"`
	Title      *string   `reform:"title" json:"title"`
	ISBN       *string   `reform:"isbn" json:"isbn"`
	Authors    *string   `reform:"authors" json:"authors"`
	URL        string    `reform:"url" json:"url"`
	CreatedAt  time.Time `reform:"created_at" json:"created_at"`
	UpdatedAt  time.Time `reform:"updated_at" json:"updated_at"`
	IsVisible  bool      `reform:"is_visible" json:"-"`
	Volumes    []string  `json:"volumes,omitempty"`
}

Book describes book entity.

func (*Book) BeforeInsert

func (b *Book) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*Book) BeforeUpdate

func (b *Book) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*Book) HasPK

func (s *Book) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Book) PKPointer

func (s *Book) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Book) PKValue

func (s *Book) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Book) Pointers

func (s *Book) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Book) SetPK

func (s *Book) SetPK(pk interface{})

SetPK sets record primary key.

func (Book) String

func (s Book) String() string

String returns a string representation of this struct or record.

func (*Book) Table

func (s *Book) Table() reform.Table

Table returns Table object for that record.

func (*Book) Values

func (s *Book) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Book) View

func (s *Book) View() reform.View

View returns View object for that struct.

type BookBroken

type BookBroken struct {
	ID        int32     `reform:"id,pk" json:"id"`
	URL       string    `reform:"url" json:"url"`
	CreatedAt time.Time `reform:"created_at" json:"created_at"`
	UpdatedAt time.Time `reform:"updated_at" json:"updated_at"`
}

Book describes a broken (not recognizable) book.

func (*BookBroken) BeforeInsert

func (b *BookBroken) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*BookBroken) BeforeUpdate

func (b *BookBroken) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*BookBroken) HasPK

func (s *BookBroken) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*BookBroken) PKPointer

func (s *BookBroken) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*BookBroken) PKValue

func (s *BookBroken) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*BookBroken) Pointers

func (s *BookBroken) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*BookBroken) SetPK

func (s *BookBroken) SetPK(pk interface{})

SetPK sets record primary key.

func (BookBroken) String

func (s BookBroken) String() string

String returns a string representation of this struct or record.

func (*BookBroken) Table

func (s *BookBroken) Table() reform.Table

Table returns Table object for that record.

func (*BookBroken) Values

func (s *BookBroken) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*BookBroken) View

func (s *BookBroken) View() reform.View

View returns View object for that struct.

type Category

type Category struct {
	ID        int32     `reform:"id,pk"`
	Title     string    `reform:"title"`
	CreatedAt time.Time `reform:"created_at"`
	UpdatedAt time.Time `reform:"updated_at"`
}

Category describes book category.

func (*Category) BeforeInsert

func (c *Category) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*Category) BeforeUpdate

func (c *Category) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*Category) HasPK

func (s *Category) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Category) PKPointer

func (s *Category) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Category) PKValue

func (s *Category) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Category) Pointers

func (s *Category) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Category) SetPK

func (s *Category) SetPK(pk interface{})

SetPK sets record primary key.

func (Category) String

func (s Category) String() string

String returns a string representation of this struct or record.

func (*Category) Table

func (s *Category) Table() reform.Table

Table returns Table object for that record.

func (*Category) Values

func (s *Category) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Category) View

func (s *Category) View() reform.View

View returns View object for that struct.

type Library

type Library struct {
	ID        int32     `reform:"id,pk" json:"id"`
	UserID    int32     `reform:"user_id" json:"-"`
	VolumeID  int32     `reform:"volume_id" json:"volume_id"`
	CreatedAt time.Time `reform:"created_at" json:"created_at"`
	UpdatedAt time.Time `reform:"updated_at" json:"updated_at"`
}

Library describes library of the user.

func (*Library) BeforeInsert

func (l *Library) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*Library) BeforeUpdate

func (l *Library) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*Library) HasPK

func (s *Library) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Library) PKPointer

func (s *Library) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Library) PKValue

func (s *Library) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Library) Pointers

func (s *Library) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Library) SetPK

func (s *Library) SetPK(pk interface{})

SetPK sets record primary key.

func (Library) String

func (s Library) String() string

String returns a string representation of this struct or record.

func (*Library) Table

func (s *Library) Table() reform.Table

Table returns Table object for that record.

func (*Library) Values

func (s *Library) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Library) View

func (s *Library) View() reform.View

View returns View object for that struct.

type User

type User struct {
	ID        int32     `reform:"id,pk"`
	Email     string    `reform:"email"`
	Token     string    `reform:"token"`
	CreatedAt time.Time `reform:"created_at"`
	UpdatedAt time.Time `reform:"updated_at"`
}

User describes some user entity.

func (*User) BeforeInsert

func (u *User) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*User) BeforeUpdate

func (u *User) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*User) HasPK

func (s *User) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*User) PKPointer

func (s *User) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*User) PKValue

func (s *User) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*User) Pointers

func (s *User) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*User) SetPK

func (s *User) SetPK(pk interface{})

SetPK sets record primary key.

func (User) String

func (s User) String() string

String returns a string representation of this struct or record.

func (*User) Table

func (s *User) Table() reform.Table

Table returns Table object for that record.

func (*User) Values

func (s *User) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*User) View

func (s *User) View() reform.View

View returns View object for that struct.

type Volume

type Volume struct {
	ID        int32     `reform:"id,pk"`
	BookID    int32     `reform:"book_id"`
	Type      string    `reform:"type"`
	CreatedAt time.Time `reform:"created_at"`
	UpdatedAt time.Time `reform:"updated_at"`
}

Volume describes "type" of book - paperbook, ebook or audiobook.

func (*Volume) BeforeInsert

func (v *Volume) BeforeInsert() error

BeforeInsert set CreatedAt and UpdatedAt.

func (*Volume) BeforeUpdate

func (v *Volume) BeforeUpdate() error

BeforeUpdate set UpdatedAt.

func (*Volume) HasPK

func (s *Volume) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Volume) PKPointer

func (s *Volume) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Volume) PKValue

func (s *Volume) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Volume) Pointers

func (s *Volume) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Volume) SetPK

func (s *Volume) SetPK(pk interface{})

SetPK sets record primary key.

func (Volume) String

func (s Volume) String() string

String returns a string representation of this struct or record.

func (*Volume) Table

func (s *Volume) Table() reform.Table

Table returns Table object for that record.

func (*Volume) Values

func (s *Volume) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Volume) View

func (s *Volume) View() reform.View

View returns View object for that struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL