DB

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDb

func CloseDb()

func GetDb

func GetDb() *gorm.DB

func InitDb

func InitDb(opt *Opt) error

Types

type BaseModel

type BaseModel struct {
	Id        int64           `json:"id"  gorm:"primaryKey"`
	CreatedAt *time.Time      `json:"created_at,omitempty" `
	UpdatedAt *time.Time      `json:"updated_at,omitempty" `
	DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" `
}

添加软删除

type CommModel

type CommModel struct {
	Id        int64      `json:"id"  gorm:"primaryKey"`
	CreatedAt *time.Time `json:"created_at,omitempty" `
	UpdatedAt *time.Time `json:"updated_at,omitempty" `
}

type DBCondition

type DBCondition func(db *gorm.DB) *gorm.DB

func GetNameLikeCondition

func GetNameLikeCondition(name string) DBCondition

func GetOrder

func GetOrder(order string) DBCondition

func GetTitleLikeCondition

func GetTitleLikeCondition(title string) DBCondition

func Paginate

func Paginate(page, pageSize int) DBCondition

type Opt

type Opt struct {
	Dsn                               string //master
	MaxIdle                           int
	MaxOpen                           int
	LogMode                           logger.LogLevel
	Models                            []any
	DisableForeignKeyCheckWhenMigrate bool
	NamingStrategySingularTable       bool
}

Jump to

Keyboard shortcuts

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