database

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDBRecordNotFound = gorm.ErrRecordNotFound

ErrDBRecordNotFound 未查询到数据库记录

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

DB Gorm封装

func NewDatabase

func NewDatabase(opts Options) (*DB, error)

NewDatabase 创建新的数据库对象

func (*DB) Begin

func (db *DB) Begin() *DB

Begin is ...

func (*DB) Close

func (db *DB) Close() error

Close 关闭数据库连接

func (*DB) Commit

func (db *DB) Commit() *DB

Commit is ...

func (*DB) Rollback

func (db *DB) Rollback() *DB

Rollback is ...

type Options

type Options struct {
	Driver    string `yaml:"driver" mapstructure:"driver"`
	Dsn       string `yaml:"dsn" mapstructure:"dsn"`
	KeepAlive int    `yaml:"keep_alive" mapstructure:"keep_alive"`
	MaxIdles  int    `yaml:"max_idles" mapstructure:"max_idles"`
	MaxOpens  int    `yaml:"max_opens" mapstructure:"max_opens"`
}

Options 创建数据库的选项

Jump to

Keyboard shortcuts

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