models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 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 Category

type Category struct {
	common.SlugModel
	Title    string     `gorm:"index;not null;unique" json:"title" example:"Mobile"`
	Products []Products `gorm:"foreignKey:CategorySlug;references:Slug"`
}

func (*Category) BeforeCreate

func (c *Category) BeforeCreate(*gorm.DB) error

type CommentLikes

type CommentLikes struct {
	common.Model
	CommentsID int `gorm:"column:comment_id"`
	UsersID    int `gorm:"column:user_id"`
}

type Comments

type Comments struct {
	common.Model
	Message      string `gorm:"not null;index"`
	UsersID      int    `gorm:"column:user_id"`
	ProductsSlug string `gorm:"column:product_slug"`
	Likes        uint
}

type ProductImages

type ProductImages struct {
	common.Model
	URL          string
	ProductsSlug string `gorm:"column:product_slug"`
}

type Products

type Products struct {
	common.SlugModel
	Name         string          `gorm:"size:75;not null;index" example:"Phone"`
	Description  string          `gorm:"size:300;not null" example:"Phone Description"`
	Price        float64         `gorm:"not null" example:"599"`
	Stock        int             `gorm:"not null" example:"6"`
	IsAvailable  bool            `gorm:"not null" example:"true"`
	Weight       float64         `gorm:"not null" example:"0.7"`
	Views        int             `gorm:"not null"`
	CategorySlug string          `gorm:"not null" json:"category_slug" example:"digital"`
	Images       []ProductImages `gorm:"foreignKey:ProductsSlug;references:Slug"`
	Comments     []Comments      `gorm:"foreignKey:ProductsSlug;references:Slug"`
	Tags         []Tags          `gorm:"many2many:product_tags"`
}

func (*Products) BeforeSave

func (p *Products) BeforeSave(*gorm.DB) error

type Tags

type Tags struct {
	common.ModelCreate
	Name string `gorm:"not null;index;unique"`
}

type Users

type Users struct {
	common.Model
	FirstName string     `gorm:"size:75;not null" json:"first_name"`
	LastName  string     `gorm:"size:75;not null" json:"last_name"`
	Phone     string     `gorm:"size:75;not null;index;unique" json:"phone"`
	Password  string     `gorm:"size:300;not null" json:"-"`
	IsActive  bool       `gorm:"not null;default:false" json:"is_active"`
	IsAdmin   bool       `gorm:"not null;default:false" json:"is_admin"`
	Comments  []Comments `gorm:"foreignKey:UsersID;references:ID"`
}

Jump to

Keyboard shortcuts

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