orm

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMongoDbClient

func InitMongoDbClient(dbConf MongoDBConf) (*mongo.Database, error)

func InitMysqlClient

func InitMysqlClient(conf MysqlConf) (client *gorm.DB, err error)

func NormalPaginate

func NormalPaginate(page *NormalPage) func(db *gorm.DB) *gorm.DB

分页示例

Types

type CrudModel

type CrudModel struct {
	CreatedAt time.Time      `json:"createdAt" gorm:"comment:创建时间"`
	UpdatedAt time.Time      `json:"updatedAt" gorm:"comment:最后更新时间"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`
}

type MongoDBConf

type MongoDBConf struct {
	DataBase string `yaml:"database"`
	Addr     string `yaml:"addr"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type MysqlConf

type MysqlConf struct {
	DataBase        string        `yaml:"database"`
	Addr            string        `yaml:"addr"`
	User            string        `yaml:"user"`
	Password        string        `yaml:"password"`
	Charset         string        `yaml:"charset"`
	MaxIdleConns    int           `yaml:"maxidleconns"`
	MaxOpenConns    int           `yaml:"maxopenconns"`
	ConnMaxIdlTime  time.Duration `yaml:"maxIdleTime"`
	ConnMaxLifeTime time.Duration `yaml:"connMaxLifeTime"`
	ConnTimeOut     time.Duration `yaml:"connTimeOut"`
	WriteTimeOut    time.Duration `yaml:"writeTimeOut"`
	ReadTimeOut     time.Duration `yaml:"readTimeOut"`
}

type NormalPage

type NormalPage struct {
	No      int    // 当前第几页
	Size    int    // 每页大小
	OrderBy string `json:"orderBy"` // 排序规则
}

type Option

type Option struct {
	IsNeedCnt  bool `json:"isNeedCnt"`
	IsNeedPage bool `json:"isNeedPage"`
}

Jump to

Keyboard shortcuts

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