database

package
v0.0.0-...-0aa8bca Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MySQLDatabaseDriver = "mysql"

Variables

This section is empty.

Functions

func EqualInt64

func EqualInt64(field string, value int64) func(db *gorm.DB) *gorm.DB

func EqualString

func EqualString(field, value string) func(db *gorm.DB) *gorm.DB

func Paginate

func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB

Types

type Connector

type Connector interface {
	Connect(o *Option) (*Store, error)
}

func NewConnector

func NewConnector() Connector

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

type ExecFunc

type ExecFunc func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

type OpenConnection

type OpenConnection func(driverName, dataSourceName string) (*sqlx.DB, error)

type Option

type Option struct {
	MasterConnectionString string
	SlaveConnectionString  string
	MaxIdleConn            int
	MaxConn                int
}

type Store

type Store struct {
	Master *sqlx.DB
	Slave  *sqlx.DB
}

func (*Store) GetExecContext

func (s *Store) GetExecContext(dbtx DBTX) DBTX

func (*Store) GetMaster

func (s *Store) GetMaster() *sqlx.DB

func (*Store) GetSelectContext

func (s *Store) GetSelectContext(dbtx DBTX) DBTX

func (*Store) GetSlave

func (s *Store) GetSlave() *sqlx.DB

Jump to

Keyboard shortcuts

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