models

package
v0.0.0-...-ceb7878 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Brand

type Brand struct {
	gorm.Model
	Name         string            `json:"name" gorm:"size:100;unique_index;not null" validate:"required"`
	Description  string            `json:"description" gorm:"size:255"`
	Products     []Product         `json:"-" gorm:"foreignkey:BrandID" validate:"dive"`
	Collections  []BrandCollection `json:"-" gorm:"foreignkey:BrandID"`
	OtherDetails string            `json:"otherDetails" gorm:"size:255"`
}

Brand data model

type BrandCollection

type BrandCollection struct {
	gorm.Model
	Name         string    `json:"name" validate:"required" gorm:"size:100"`
	Description  string    `json:"description" gorm:"size:255"`
	Products     []Product `json:"-" gorm:"many2many:brand_collection_products;" validate:"dive" `
	Brand        Brand     `json:"brand" gorm:"foreignkey:BrandID;association_autoupdate:false;association_autocreate:false"`
	BrandID      uint      `json:"brandID"`
	OtherDetails string    `json:"otherDetails" gorm:"size:255"`
}

BrandCollection Collection to specific Brand

type BrandInput

type BrandInput struct {
	Name         string `json:"name" validate:"gte=2,required"`
	Description  string `json:"description"`
	OtherDetails string `json:"otherDetails"`
}

BrandInput used when create or update data

type Collection

type Collection struct {
	gorm.Model
	Name         string    `json:"name" validate:"required" gorm:"size:100"`
	Description  string    `json:"description" gorm:"size:255"`
	Products     []Product `json:"-" gorm:"many2many:collection_products;" validate:"dive" `
	OtherDetails string    `json:"otherDetails" gorm:"size:255"`
}

Collection of products data model

type CollectionInput

type CollectionInput struct {
	Name         string `json:"name" validate:"required"`
	Description  string `json:"description"`
	Products     []int  `json:"products" validate:"required,min=1,unique"`
	OtherDetails string `json:"otherDetails"`
	BrandID      uint   `json:"brandID"`
}

CollectionInput collection Input

type Product

type Product struct {
	gorm.Model
	Name         string  `json:"name" validate:"required" gorm:"size:100"`
	Code         *string `json:"code" gorm:"size:30;unique_index;not null" validate:"required"`
	Description  string  `json:"description" gorm:"size:255"`
	OtherDetails string  `json:"otherDetails" gorm:"size:255"`
	Brand        Brand   `json:"brand" gorm:"foreignkey:BrandID;association_autoupdate:false;association_autocreate:false"`
	BrandID      uint    `json:"brandID"`
}

Product data model

type ProductInput

type ProductInput struct {
	Name         string  `json:"name" validate:"required"`
	Code         *string `json:"code" validate:"required"`
	Description  string  `json:"description"`
	OtherDetails string  `json:"otherDetails"`
	BrandID      uint    `json:"brandID"`
}

ProductInput data model

Jump to

Keyboard shortcuts

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