db

package
v0.0.0-...-1837051 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() *gorm.DB

Connect return a pointer to MySQL Connection

func New

func New()

New start a connection on a dabasase

Types

type Company

type Company struct {
	ID       uint   ` json:"id" gorm:"primary_key;AUTO_INCREMENT"`
	Name     string ` json:"name" gorm:"type:varchar(100)"`
	Email    string ` json:"email" gorm:"type:varchar(100);unique_index;not null"`
	Phone    string ` json:"phone" gorm:"type:varchar(30)"`
	Products []Product
	Users    []User
	gorm.Model
}

Company struct

type Product

type Product struct {
	gorm.Model
	Title     string `gorm:"type:varchar(100)"`
	CompanyID uint
}

Product struct

type User

type User struct {
	gorm.Model
	Name      string
	Email     string `gorm:"type:varchar(100);unique_index"`
	CompanyID uint
	Products  []Product `gorm:"many2many:user_product;"`
}

User struct

Jump to

Keyboard shortcuts

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