rdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PG    = "postgres"
	MYSQL = "mysql"
)

Variables

This section is empty.

Functions

func NewMysqlUrl

func NewMysqlUrl(c DbConfig) string

func NewMysqlUrl2

func NewMysqlUrl2(c DbConfig) string

func NewPqUrl

func NewPqUrl(c DbConfig) string

Types

type DbConfig

type DbConfig struct {
	Name    string `yaml:"name"`
	Host    string `yaml:"host"`
	User    string `yaml:"user"`
	Pass    string `yaml:"pass"`
	Port    string `yaml:"port"`
	Prefix  string
	SslMode string
}

type MyDb

type MyDb struct {
	Config MyDbConfig
	Client *xorm.Engine
}

func NewDb

func NewDb(config MyDbConfig) (*MyDb, error)

func (*MyDb) CreateTables

func (db *MyDb) CreateTables(beanOrTableName interface{}) error

func (*MyDb) Delete

func (db *MyDb) Delete(bean interface{}) (int64, error)

func (*MyDb) DropTables

func (db *MyDb) DropTables(beans ...interface{}) error

func (*MyDb) Insert

func (db *MyDb) Insert(beans ...interface{}) (int64, error)

func (*MyDb) InsertOne

func (db *MyDb) InsertOne(beans interface{}) (int64, error)

func (*MyDb) IsTableExist

func (db *MyDb) IsTableExist(beanOrTableName interface{}) (bool, error)

func (*MyDb) SetConnMaxLifetime

func (db *MyDb) SetConnMaxLifetime(lifeTime time.Duration)

func (*MyDb) Update

func (db *MyDb) Update(bean interface{}, condiBean ...interface{}) (int64, error)

type MyDbConfig

type MyDbConfig struct {
	DriverName      string `yaml:"driver_name"`
	DbConfig        `yaml:",inline"`
	MaxIdle         int    `yaml:"max_idle"`
	MaxOpen         int    `yaml:"max_open"`
	DebugToFile     bool   `yaml:"debug_to_file"`
	DebugToFileName string `yaml:"debug_to_file_path"`
	Debug           bool   `yaml:"debug"`
}

Jump to

Keyboard shortcuts

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