db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*DBResourceManager
}

Db

func NewDb

func NewDb(conf *config.Config) (*DB, error)

NewDb

func (*DB) NewDBTable

func (s *DB) NewDBTable(dbname string, tableName string) *Repo

type DBConfig

type DBConfig struct {
	MaxIdle     int    `json:"max_idle" toml:"max_idle" yaml:"max_idle" mapstructure:"max_idle"`
	MaxOpen     int    `json:"max_open" toml:"max_open" yaml:"max_open" mapstructure:"max_open"`
	MaxIdleLife int    `json:"max_idle_life" toml:"max_idle_life" yaml:"max_idle_life" mapstructure:"max_idle_life"`
	IsDebug     bool   `json:"is_debug" toml:"is_debug" yaml:"is_debug" mapstructure:"is_debug"`
	Datasource  string `json:"data_source" toml:"data_source" yaml:"data_source" mapstructure:"data_source"`
	DbType      string `json:"-" toml:"-" yaml:"-" mapstructure:"-"`
}

type DBResourceManager

type DBResourceManager struct {
	// contains filtered or unexported fields
}

func New

func New(conf *viper.Viper) *DBResourceManager

func (*DBResourceManager) Get

func (db *DBResourceManager) Get(name string) *DatabaseManager

type DatabaseManager

type DatabaseManager struct {
	WriteDB *xorm.Engine
	// contains filtered or unexported fields
}

DatabaseManager

func (*DatabaseManager) Ping

func (db *DatabaseManager) Ping() error

Ping Database

type Repo

type Repo struct {
	Engine *xorm.Engine
	// contains filtered or unexported fields
}

Repo Reference xorm

func (*Repo) Exec

func (repo *Repo) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*Repo) Find

func (repo *Repo) Find(bean interface{}, condiBeans ...interface{}) error

func (*Repo) Get

func (repo *Repo) Get(bean interface{}) (bool, error)

func (*Repo) In

func (repo *Repo) In(column string, args ...interface{}) *xorm.Session

func (*Repo) Insert

func (repo *Repo) Insert(beans ...interface{}) (int64, error)

func (*Repo) InsertOne

func (repo *Repo) InsertOne(beans interface{}) (int64, error)

func (*Repo) NewSession

func (repo *Repo) NewSession() *xorm.Session

func (*Repo) Query

func (repo *Repo) Query(sql string, paramStr ...interface{}) (resultsSlice []map[string][]byte, err error)

func (*Repo) Select

func (repo *Repo) Select(query string) *xorm.Session

func (*Repo) SetTableName

func (repo *Repo) SetTableName(name string)

func (*Repo) ShowSQL

func (repo *Repo) ShowSQL(b bool)

func (*Repo) Where

func (repo *Repo) Where(query interface{}, args ...interface{}) *xorm.Session

Jump to

Keyboard shortcuts

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