db

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

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

Go to latest
Published: Feb 27, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenderMale   = true
	GenderFemale = false
)
View Source
const (
	LanguageCodeRussian = "RU"
	LanguageCodeEnglish = "EN"
)

Variables

View Source
var DB *gorm.DB

Functions

func InitConn

func InitConn(conf config.DBConf, logger echo.Logger)

Types

type BaseModel

type BaseModel struct {
	ID        uuid.UUID      `gorm:"column:id;primaryKey;type:uuid;not null"`
	CreatedAt time.Time      `gorm:"column:created_at;type:timestamp without time zone;not null;index"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:timestamp without time zone;not null"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;default:null;index"`
}

func (*BaseModel) BeforeCreate

func (m *BaseModel) BeforeCreate(tx *gorm.DB) error

type Customer

type Customer struct {
	BaseModel
	FirstName string    `gorm:"column:first_name;type:varchar(100);not null"`
	LastName  string    `gorm:"column:last_name;type:varchar(100);not null"`
	BirthDate time.Time `gorm:"column:birth_date;type:date;not null"`
	Gender    bool      `gorm:"column:gender;type:boolean;not null"`
	Email     string    `gorm:"column:email;type:varchar(255);not null;index:idx_customers_email_user_id_unique,unique"`
	Address   *string   `gorm:"column:address;type:varchar(200);default:null"`
	UserID    uuid.UUID `gorm:"column:user_id;type:uuid;not null;index:idx_customers_email_user_id_unique,unique;index"`
}

type User

type User struct {
	BaseModel
	Email       string     `gorm:"column:email;type:varchar(255);not null;uniqueIndex"`
	Password    string     `gorm:"column:password;type:char(60);not null"`
	AccessToken *uuid.UUID `gorm:"column:access_token;type:uuid;default:null"`
	Language    string     `gorm:"column:language;type:char(2);not null"`
	CreatedAt   time.Time  `gorm:"column:created_at;type:timestamp without time zone;not null"`
	UpdatedAt   time.Time  `gorm:"column:updated_at;type:timestamp without time zone;not null"`
	DeletedAt   *time.Time `gorm:"column:deleted_at;type:timestamp without time zone;default:null;index"`
	Customers   []Customer `gorm:"ForeignKey:UserID"`
}

Jump to

Keyboard shortcuts

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