models

package
v0.0.0-...-0efcf47 Latest Latest
Warning

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

Go to latest
Published: Sep 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, offset int) interface{}
}

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"`
	Desctiption string  `json:"description"`
	Image       string  `json:"image"`
	Price       float64 `json:"price"`
}

func (*Product) Count

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

func (*Product) Take

func (p *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 `gorm:"unique" json:"email"`
	Password  []byte `json:"-"`
	RoleId    uint   `json:"role_id"`
	Role      Role   `json:"role" gorm:"foreignKey:RoleId"`
}

func (*User) ComparePassword

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

func (*User) Count

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

func (*User) SetPassword

func (u *User) SetPassword(password string)

func (*User) Take

func (u *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