models

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID        uint64 `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Firstname string `json:"firstname" gorm:"size:255" validate:"required,min=1,max=255"`
	Surname   string `json:"surname" gorm:"size:255" validate:"required,min=1,max=255"`
}

Author represents an author entity with ID, Firstname, and Surname.

func (*Author) TableName added in v0.4.3

func (a *Author) TableName() string

TableName returns the author table name.

func (*Author) Validate

func (a *Author) Validate(v *validator.Validate) error

Validate validates the Author struct based on defined validation tags.

type Book added in v0.8.0

type Book struct {
	ID               uint      `json:"id" gorm:"primaryKey;autoIncrement;->"`
	BranchID         uint      `json:"branch_id"`
	Branch           *Branch   `json:"branch" gorm:"foreignKey:BranchID"`
	Added            time.Time `json:"added"`
	ShortDescription string    `json:"summary"`
	Author           []*Author `json:"authors" gorm:"many2many:book_author;"`
	// Genre            *Genre         `json:"genre" gorm:"foreignKey:GenreID"`
	Price       float32    `json:"price" gorm:"default:0.00"`
	Sold        bool       `gorm:"default:false"`
	SoldOn      time.Time  `json:"sold_on,omitempty"`
	Removed     bool       `gorm:"default:false"`
	RemovedOn   time.Time  `json:"removed_on,omitempty"`
	Reserved    bool       `gorm:"default:false"`
	ReservedAt  time.Time  `json:"reserved_at,omitempty"`
	ReleaseYear time.Time  `json:"published_date"`
	Condition   *Condition `json:"condition" gorm:"foreignKey:ConditionID"`
	ConditionID uint       `json:"condition_id"`
	Tags        []*Tag     `json:"tags" gorm:"many2many:book_tag;"`
	// Reservation      []*Reservation `json:"reservations" gorm:"foreignKey:BookID"`
	Recommendation bool `json:"recommendations" gorm:"foreignKey:BookID"`
	Inventory      bool `gorm:"default:false"`
	// Format           *Format        `json:"format" gorm:"foreignKey:FormatID"`
	FormatID  uint   `json:"format_id"`
	Subtitle  string `json:"subtitle" validate:"max=255"`
	Duplicate bool   `gorm:"default:false"`
}

Book represents a book entity.

func (Book) TableName added in v0.8.0

func (Book) TableName() string

TableName overrides the default table name for Book model.

type Branch added in v0.6.0

type Branch struct {
	ID        uint    `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name      string  `json:"name" validate:"required,max=255"`
	Steps     float32 `json:"steps" validate:"gte=0.00" gorm:"default:0.00"`
	Currency  string  `json:"currency" validate:"required,oneof=EUR USD" gorm:"default:'EUR'"`
	Ordering  string  `json:"ordering" gorm:"type:text"`
	Public    bool    `json:"public" gorm:"default:false"`
	Pricelist string  `json:"pricelist" gorm:"type:text"`
	Cart      bool    `json:"cart" gorm:"default:false"`
	Content   string  `json:"content" gorm:"type:text"`
}

Branch represents a branch entity with various attributes.

func (*Branch) TableName added in v0.6.0

func (b *Branch) TableName() string

TableName returns the branch table name.

func (*Branch) Validate added in v0.6.0

func (b *Branch) Validate(v *validator.Validate) error

Validate validates the Branch struct based on defined validation tags.

type Condition added in v0.7.0

type Condition struct {
	ID       uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name     string `json:"name" gorm:"type:varchar(255);not null;unique" validate:"required,min=1,max=255"`
	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`
}

Condition model represents a book's condition.

func (Condition) TableName added in v0.7.0

func (Condition) TableName() string

TableName overrides the default table name for Condition model.

func (*Condition) Validate added in v0.7.0

func (c *Condition) Validate(db *gorm.DB) bool

Validate validates the Condition model based on defined rules.

type Tabler added in v0.6.0

type Tabler interface {
	TableName() string
}

Tabler interface for table name.

type Tag added in v0.8.0

type Tag struct {
	ID   uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name string `json:"name" validate:"required,max=255"`

	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`

	Books []*Book `json:"books" gorm:"many2many:book_tag;"`
}

Tag represents a tag model.

func (Tag) TableName added in v0.8.0

func (Tag) TableName() string

TableName overrides the default table name.

func (*Tag) Validate added in v0.8.0

func (t *Tag) Validate(db *gorm.DB) bool

Validate validates the Tag model.

Jump to

Keyboard shortcuts

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