orm

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CreateTimeAsc  = Asc(createTime)
	UpdateTimeAsc  = Asc(updateTime)
	CreateTimeDesc = Desc(createTime)
	UpdateTimeDesc = Desc(updateTime)
	IdDesc         = Desc(id)
)

Functions

func Asc added in v1.5.8

func Asc(field string) string

func C

func C() *gorm.DB

func Desc added in v1.5.8

func Desc(field string) string

func Init

func Init(opt *InitOption)

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
	SkipDefaultTransaction bool
}

type Model

type Model struct {
	ID        uint           `gorm:"primaryKey;index" json:"id"`
	CreatedAt time.Time      `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;index" json:"id"`
	CreatedAt time.Time      `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(_ *gorm.DB) error

Jump to

Keyboard shortcuts

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