Documentation
¶
Index ¶
- func InjectTx(ctx context.Context, s SqlGdbc) context.Context
- type DatabaseConnector
- type EnableTransactor
- type Gdbc
- func (g *Gdbc) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (g *Gdbc) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (g *Gdbc) Prepare(ctx context.Context, query string) (*sql.Stmt, error)
- func (g *Gdbc) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (g *Gdbc) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (g *Gdbc) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (g *Gdbc) WithinTransaction(ctx context.Context, txFunc func(ctx context.Context) error) error
- func (g *Gdbc) WithinTransactionOptions(ctx context.Context, txFunc func(ctx context.Context) error, ...) error
- type PoolOptions
- type SqlGdbc
- type SqlxConnTx
- func (s *SqlxConnTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *SqlxConnTx) Get(dest interface{}, query string, args ...interface{}) error
- func (s *SqlxConnTx) Prepare(query string) (*sql.Stmt, error)
- func (s *SqlxConnTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (s *SqlxConnTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (s *SqlxConnTx) Select(dest interface{}, query string, args ...interface{}) error
- func (sct *SqlxConnTx) WithinTransaction(ctx context.Context, txFunc func(ctx context.Context) error) error
- func (sct *SqlxConnTx) WithinTransactionOptions(ctx context.Context, txFunc func(ctx context.Context) error, ...) error
- type SqlxDBTx
- func (s *SqlxDBTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *SqlxDBTx) Get(dest interface{}, query string, args ...interface{}) error
- func (s *SqlxDBTx) Prepare(query string) (*sql.Stmt, error)
- func (s *SqlxDBTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (s *SqlxDBTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (s *SqlxDBTx) Select(dest interface{}, query string, args ...interface{}) error
- func (sdt *SqlxDBTx) WithinTransaction(ctx context.Context, txFunc func(ctx context.Context) error) error
- func (sdt *SqlxDBTx) WithinTransactionOptions(ctx context.Context, txFunc func(ctx context.Context) error, ...) error
- type SqlxDatabaseConnector
- type Transactor
- type TxKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DatabaseConnector ¶ added in v1.0.0
type DatabaseConnector interface { // Connect to database using: // 1. drivername // 2. dsn(connection string) // 3. poolOptions: nil if no need to configure pool Connect(drivername string, dsn string, poolOptions *PoolOptions) (*Gdbc, error) }
func NewSqlxDatabaseConnector ¶ added in v1.0.0
func NewSqlxDatabaseConnector() DatabaseConnector
type EnableTransactor ¶
type Gdbc ¶
type Gdbc struct {
// contains filtered or unexported fields
}
Used this in repositories
func (*Gdbc) Select ¶
func (g *Gdbc) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Select implements SqlGdbc.
func (*Gdbc) WithinTransaction ¶
type PoolOptions ¶
type PoolOptions struct { MaxIdleCount int // zero means defaultMaxIdleConns; negative means 0 MaxOpen int // <= 0 means unlimited MaxLifetime time.Duration // maximum amount of time a connection may be reused MaxIdleTime time.Duration // maximum amount of time a connection may be idle before being closed }
type SqlGdbc ¶
type SqlGdbc interface { Transactor Exec(query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row Get(dest interface{}, query string, args ...interface{}) error Select(dest interface{}, query string, args ...interface{}) error }
SqlGdbc (SQL Go database connection) is a wrapper for SQL database handler ( can be *sql.DB or *sql.Tx) It should be able to work with all SQL data that follows SQL standard.
type SqlxConnTx ¶ added in v1.0.0
SqlxConnx is the sqlx.Tx based implementation of GDBC
func NewSqlxConnGdbc ¶ added in v1.0.0
func NewSqlxConnGdbc(db *sqlx.Tx) *SqlxConnTx
func (*SqlxConnTx) Exec ¶ added in v1.0.0
func (s *SqlxConnTx) Exec(query string, args ...interface{}) (sql.Result, error)
Exec implements SqlGdbc.
func (*SqlxConnTx) Get ¶ added in v1.0.0
func (s *SqlxConnTx) Get(dest interface{}, query string, args ...interface{}) error
Get implements database.SqlGdbc.
func (*SqlxConnTx) Prepare ¶ added in v1.0.0
func (s *SqlxConnTx) Prepare(query string) (*sql.Stmt, error)
Prepare implements SqlGdbc.
func (*SqlxConnTx) Query ¶ added in v1.0.0
func (s *SqlxConnTx) Query(query string, args ...interface{}) (*sql.Rows, error)
Query implements SqlGdbc.
func (*SqlxConnTx) QueryRow ¶ added in v1.0.0
func (s *SqlxConnTx) QueryRow(query string, args ...interface{}) *sql.Row
QueryRow implements SqlGdbc.
func (*SqlxConnTx) Select ¶ added in v1.0.0
func (s *SqlxConnTx) Select(dest interface{}, query string, args ...interface{}) error
Select implements database.SqlGdbc.
func (*SqlxConnTx) WithinTransaction ¶ added in v1.0.0
type SqlxDBTx ¶ added in v1.0.0
SqlxDBx is the sqlx.DB based implementation of GDBC
func NewSqlxDBGdbc ¶ added in v1.0.0
func (*SqlxDBTx) WithinTransaction ¶ added in v1.0.0
type SqlxDatabaseConnector ¶ added in v1.0.0
type SqlxDatabaseConnector struct { }
func (*SqlxDatabaseConnector) Connect ¶ added in v1.0.0
func (c *SqlxDatabaseConnector) Connect(driverName string, dsn string, poolOptions *PoolOptions) (*Gdbc, error)
type Transactor ¶
Click to show internal directories.
Click to hide internal directories.