db

package
v0.0.0-...-6dcb45d Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() (err error)

关闭数据库。

func GetDB

func GetDB() *gorm.DB

获取数据库连接对象。

func InitDefaultDB

func InitDefaultDB(source, driver string, cfg *gorm.Config) (db *gorm.DB, err error)

初始化默认数据库

func NewDB

func NewDB(source, driver string, cfg *gorm.Config) (db *gorm.DB, err error)

新建数据库

Types

type Paginator

type Paginator struct {
	TotalRecord int64       `json:"total_record"`
	TotalPage   int         `json:"total_page"`
	Records     interface{} `json:"list"`
	Offset      int         `json:"offset"`
	Limit       int         `json:"limit"`
	Page        int         `json:"page"`
	PrevPage    int         `json:"prev_page"`
	NextPage    int         `json:"next_page"`
}

Paginator 分页返回

func Paging

func Paging(p *Param, result interface{}) (*Paginator, error)

Paging 分页

type Param

type Param struct {
	DB      *gorm.DB
	Page    int
	Limit   int
	OrderBy []string
	ShowSQL bool
}

Param 分页参数

Jump to

Keyboard shortcuts

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