db

package
v0.0.0-...-61fbec9 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 3 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 OpenDB

func OpenDB(conf *DBConfiguration) *gorm.DB

打开数据库

func Tx

func Tx(db *gorm.DB, txFunc func(tx *gorm.DB) error) (err error)

事务环绕

Types

type DBConfiguration

type DBConfiguration struct {
	Dialect        string
	Url            string
	MaxIdle        int
	MaxActive      int
	EnableLogModel bool
	Models         []interface{}
}

type GormModel

type GormModel struct {
	Id int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
}

type OrderByCol

type OrderByCol struct {
	Column string // 排序字段
	Asc    bool   // 是否正序
}

排序信息

type PageResult

type PageResult struct {
	Page    *Paging     `json:"page"`    // 分页信息
	Results interface{} `json:"results"` // 数据
}

分页返回数据

type Paging

type Paging struct {
	Page  int `json:"page"`  // 页码
	Limit int `json:"limit"` // 每页条数
	Total int `json:"total"` // 总数据条数
}

分页请求数据

func (*Paging) Offset

func (p *Paging) Offset() int

func (*Paging) TotalPage

func (p *Paging) TotalPage() int

Jump to

Keyboard shortcuts

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