database

package
v0.5.16 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQL      = "mysql"
	PostgreSQL = "postgres"
	SQLite     = "sqlite"
	SQLServer  = "sqlserver"
	Clickhouse = "clickhouse"
)

Variables

This section is empty.

Functions

func GetGorm added in v0.5.2

func GetGorm(name string) (db *gorm.DB, put func(), err error)

GetGorm 获取一个 gorm 连接

func GetMongo added in v0.1.13

func GetMongo(name string) (db *mgo.Database, put func(), err error)

GetMongo 获取一个 mongodb连接

func GetMysql

func GetMysql(name string) (db *gorm.DB, put func(), err error)

GetMysql 获取一个mysql db连接

func GetPostgre added in v0.2.33

func GetPostgre(name string) (db *pgo.DB, put func(), err error)

GetPostgre 获取一个GetPostgre连接

func GetRedis

func GetRedis(name string) (db redis.Conn, put func(), err error)

GetRedis 获取一个db连接

func PutConn

func PutConn(put func())

PutConn 将连接放回连接池方法

func RegisterAll added in v0.3.1

func RegisterAll()

RegisterAll 注册所有支持的驱动

Types

type DataBase

type DataBase interface {
	RegisterAll()
	Register(string)
	// contains filtered or unexported methods
}

func NewGorm added in v0.5.2

func NewGorm() DataBase

NewGorm 初始化 gorm 连接

func NewMongo added in v0.1.13

func NewMongo() DataBase

NewMysql 初始化mysql连接

func NewMysql

func NewMysql() DataBase

NewMysql 初始化mysql连接

func NewPostgre added in v0.2.33

func NewPostgre() DataBase

NewPostgre 初始化Postgre连接

func NewRedis

func NewRedis() DataBase

NewRedis 初始化 redis 连接

type GormDB added in v0.5.2

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

func (*GormDB) Register added in v0.5.2

func (my *GormDB) Register(name string)

Register 注册一个db配置

func (*GormDB) RegisterAll added in v0.5.2

func (my *GormDB) RegisterAll()

注册所有已配置的db

type MongoDB added in v0.1.13

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

func (*MongoDB) Register added in v0.1.13

func (mo *MongoDB) Register(name string)

Register 注册一个mongo配置

func (*MongoDB) RegisterAll added in v0.1.13

func (mo *MongoDB) RegisterAll()

注册所有已配置的 mongo

type MysqlDB

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

func (*MysqlDB) Register

func (my *MysqlDB) Register(name string)

NewMysql 注册一个mysql配置

func (*MysqlDB) RegisterAll

func (my *MysqlDB) RegisterAll()

注册所有已配置的mysql

type PostgreDB added in v0.2.33

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

func (*PostgreDB) Register added in v0.2.33

func (pg *PostgreDB) Register(name string)

Register 注册一个postgre配置

func (*PostgreDB) RegisterAll added in v0.2.33

func (pg *PostgreDB) RegisterAll()

注册所有已配置的 postgre

type RedisDB

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

func (*RedisDB) Register

func (re *RedisDB) Register(name string)

RegisterRedis 注册一个redis配置

func (*RedisDB) RegisterAll

func (re *RedisDB) RegisterAll()

注册所有已配置的 redis

Jump to

Keyboard shortcuts

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