orm

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func C

func C() *gorm.DB

func Init

func Init(opt *InitOption) error

Types

type DbType

type DbType string
const (
	MySQL    DbType = "mysql"
	Postgres DbType = "postgres"
)

type InitOption

type InitOption struct {
	Type   DbType
	User   string
	Pass   string
	DbName string
	Host   string
	Port   int

	MaxIdleConn     int
	MaxOpenConn     int
	ConnMaxLifetime time.Duration
	LogLevel        glog.LogLevel
}

type Model

type Model struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `gorm:"index" json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

Model primary key is auto increment

type Operator

type Operator struct {
	CreatedBy string `json:"created_by"`
	UpdatedBy string `json:"updated_by"`
	DeletedBy string `json:"deleted_by"`
}

type UModel

type UModel struct {
	ID        string         `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `gorm:"index" json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

UModel primary key is uuid model

func (*UModel) BeforeCreate

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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