DB

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDb

func CloseDb()

func CloseMultiDb

func CloseMultiDb()

func GetDb

func GetDb() *gorm.DB

func GetMultiDb

func GetMultiDb(alias string) *gorm.DB

func InitMultiDb

func InitMultiDb(databases []Database) error

func InitSingleDb

func InitSingleDb(opt *SingleOpt) error

func Paginate

func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB

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 Database

type Database struct {
	Host             string
	Username         string
	Password         string
	Database         string
	Models           []interface{}
	Alias, Prefix    string
	LogMode          logger.LogLevel
	MaxIdle, MaxOpen int
}

type SingleOpt

type SingleOpt struct {
	Host         string
	Username     string
	Password     string
	Prefix       string
	DatabaseName string
	MaxIdle      int
	MaxOpen      int
	LogMode      logger.LogLevel
	Models       []interface{}
}

Jump to

Keyboard shortcuts

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