models

package
v0.0.0-...-5db0057 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate

func Paginate(db *gorm.DB, entity Entity, page int) fiber.Map

Types

type Entity

type Entity interface {
	Count(db *gorm.DB) int64
	Take(db *gorm.DB, limit int, offset int) interface{}
}

type Order

type Order struct {
	Id         uint        `json:"id"`
	FirstName  string      `json:"-"`
	LastName   string      `json:"-"`
	Name       string      `json:"name" gorm:"-"`
	Total      float32     `json:"total" gorm:"-"`
	Email      string      `json:"email"`
	UpdatedAt  string      `json:"updated_at"`
	CreateAt   string      `json:"create_at"`
	OrderItems []OrderItem `json:"order_items" gorm:"foreignKey:OrderId"`
}

func (*Order) Count

func (order *Order) Count(db *gorm.DB) int64

func (*Order) Take

func (order *Order) Take(db *gorm.DB, limit int, offset int) interface{}

type OrderItem

type OrderItem struct {
	Id           uint    `json:"id"`
	OrderId      uint    `json:"order_id"`
	ProductTitle string  `json:"product_title"`
	Price        float32 `json:"price"`
	Quantity     uint    `json:"quantity"`
}

type Permission

type Permission struct {
	Id   uint   `json:"id"`
	Name string `json:"name"`
}

type Product

type Product struct {
	Id          uint    `json:"id"`
	Title       string  `json:"title"`
	Description string  `json:"description"`
	Image       string  `json:"image"`
	Price       float64 `json:"price"`
}

func (*Product) Count

func (product *Product) Count(db *gorm.DB) int64

func (*Product) Take

func (product *Product) Take(db *gorm.DB, limit int, offset int) interface{}

type Role

type Role struct {
	Id          uint         `json:"id"`
	Name        string       `json:"name"`
	Permissions []Permission `json:"permissions" gorm:"many2many:role_permissions"`
}

type User

type User struct {
	Id        uint   `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email" gorm:"unique"`
	Password  []byte `json:"-"`
	RoleId    uint   `json:"role_Id"`
	//(role_id) -> roles (id)
	Role Role `json:"role" gorm:"foreignKey:RoleId"`
}

func (*User) ComparePassword

func (user *User) ComparePassword(password string) error

func (*User) Count

func (user *User) Count(db *gorm.DB) int64

func (*User) SetPassword

func (user *User) SetPassword(password string)

func (*User) Take

func (user *User) Take(db *gorm.DB, limit int, offset int) interface{}

Jump to

Keyboard shortcuts

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