Documentation ¶
Overview ¶
Package dbr provides the dbr functions for handling with databases. This package is wrapping package of "https://github.com/gocraft/dbr/v2".
Index ¶
- type Builder
- type Connection
- type DBR
- type DeleteStmt
- type EventReceiver
- type InsertStmt
- type MockConn
- type MockDBR
- type MockDelete
- type MockInsert
- type MockSelect
- type MockSession
- type MockTx
- func (t *MockTx) Commit() error
- func (t *MockTx) DeleteFrom(table string) DeleteStmt
- func (t *MockTx) InsertBySql(query string, value ...interface{}) InsertStmt
- func (t *MockTx) InsertInto(table string) InsertStmt
- func (t *MockTx) Rollback() error
- func (t *MockTx) RollbackUnlessCommitted()
- func (t *MockTx) Select(column ...string) SelectStmt
- type NullEventReceiver
- type SelectStmt
- type Session
- type TracingEventReceiver
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { NewSession(event EventReceiver) Session SetConnMaxLifetime(d time.Duration) SetMaxIdleConns(n int) SetMaxOpenConns(n int) }
Connection represents the interface to handle connection of database.
type DBR ¶
type DBR interface { Open(driver, dsn string, log EventReceiver) (Connection, error) Eq(col string, val interface{}) Builder }
DBR repreesnts the interface to create connection to MySQL.
type DeleteStmt ¶
type DeleteStmt interface { ExecContext(ctx context.Context) (sql.Result, error) Where(query interface{}, value ...interface{}) DeleteStmt }
DeleteStmt represents the interface to execute delete data.
type EventReceiver ¶
type EventReceiver = dbr.EventReceiver
EventReceiver is a type alias of dbr.EventReceiver.
type InsertStmt ¶
type InsertStmt interface { Columns(column ...string) InsertStmt ExecContext(ctx context.Context) (sql.Result, error) Record(structValue interface{}) InsertStmt }
InsertStmt represents the interface to insert data to database.
type MockConn ¶
type MockConn struct { NewSessionFunc func(event EventReceiver) Session SetConnMaxLifetimeFunc func(d time.Duration) SetMaxIdleConnsFunc func(n int) SetMaxOpenConnsFunc func(n int) }
func (*MockConn) NewSession ¶
func (c *MockConn) NewSession(event EventReceiver) Session
func (*MockConn) SetConnMaxLifetime ¶
func (*MockConn) SetMaxIdleConns ¶
func (*MockConn) SetMaxOpenConns ¶
type MockDBR ¶
type MockDBR struct { OpenFunc func(driver, dsn string, log EventReceiver) (Connection, error) EqFunc func(col string, val interface{}) Builder }
func (*MockDBR) Open ¶
func (d *MockDBR) Open(driver, dsn string, log EventReceiver) (Connection, error)
type MockDelete ¶
type MockDelete struct { ExecContextFunc func(ctx context.Context) (sql.Result, error) WhereFunc func(query interface{}, value ...interface{}) DeleteStmt }
func (*MockDelete) ExecContext ¶
func (*MockDelete) Where ¶
func (s *MockDelete) Where(query interface{}, value ...interface{}) DeleteStmt
type MockInsert ¶
type MockInsert struct { ColumnsFunc func(column ...string) InsertStmt ExecContextFunc func(ctx context.Context) (sql.Result, error) RecordFunc func(structValue interface{}) InsertStmt }
func (*MockInsert) Columns ¶
func (s *MockInsert) Columns(column ...string) InsertStmt
func (*MockInsert) ExecContext ¶
func (*MockInsert) Record ¶
func (s *MockInsert) Record(structValue interface{}) InsertStmt
type MockSelect ¶
type MockSelect struct { FromFunc func(table interface{}) SelectStmt WhereFunc func(query interface{}, value ...interface{}) SelectStmt LimitFunc func(n uint64) SelectStmt LoadContextFunc func(ctx context.Context, value interface{}) (int, error) }
func (*MockSelect) From ¶
func (s *MockSelect) From(table interface{}) SelectStmt
func (*MockSelect) Limit ¶
func (s *MockSelect) Limit(n uint64) SelectStmt
func (*MockSelect) LoadContext ¶
func (s *MockSelect) LoadContext(ctx context.Context, value interface{}) (int, error)
func (*MockSelect) Where ¶
func (s *MockSelect) Where(query interface{}, value ...interface{}) SelectStmt
type MockSession ¶
type MockSession struct { SelectFunc func(column ...string) SelectStmt BeginFunc func() (Tx, error) CloseFunc func() error PingContextFunc func(ctx context.Context) error }
func (*MockSession) Begin ¶
func (s *MockSession) Begin() (Tx, error)
func (*MockSession) Close ¶
func (s *MockSession) Close() error
func (*MockSession) PingContext ¶
func (s *MockSession) PingContext(ctx context.Context) error
func (*MockSession) Select ¶
func (s *MockSession) Select(column ...string) SelectStmt
type MockTx ¶
type MockTx struct { CommitFunc func() error RollbackFunc func() error RollbackUnlessCommittedFunc func() InsertBySqlFunc func(query string, value ...interface{}) InsertStmt InsertIntoFunc func(table string) InsertStmt SelectFunc func(column ...string) SelectStmt DeleteFromFunc func(table string) DeleteStmt }
func (*MockTx) DeleteFrom ¶
func (t *MockTx) DeleteFrom(table string) DeleteStmt
func (*MockTx) InsertBySql ¶
func (t *MockTx) InsertBySql(query string, value ...interface{}) InsertStmt
func (*MockTx) InsertInto ¶
func (t *MockTx) InsertInto(table string) InsertStmt
func (*MockTx) RollbackUnlessCommitted ¶
func (t *MockTx) RollbackUnlessCommitted()
func (*MockTx) Select ¶
func (t *MockTx) Select(column ...string) SelectStmt
type NullEventReceiver ¶
type NullEventReceiver = dbr.NullEventReceiver
NullEventReceiver is a type alias of dbr.NullEventReceiver.
type SelectStmt ¶
type SelectStmt interface { From(table interface{}) SelectStmt Where(query interface{}, value ...interface{}) SelectStmt Limit(n uint64) SelectStmt LoadContext(ctx context.Context, value interface{}) (int, error) }
SelectStmt represents the interface to get data from database.
type Session ¶
type Session interface { Select(column ...string) SelectStmt Begin() (Tx, error) Close() error PingContext(ctx context.Context) error }
Session represents the interface to handle session.
func NewSession ¶
func NewSession(conn Connection, event EventReceiver) Session
NewSession creates the session with event and returns the Session interface.
type TracingEventReceiver ¶
type TracingEventReceiver = dbr.TracingEventReceiver
TracingEventReceiver is a type alias of dbr.TracingEventReceiver.
type Tx ¶
type Tx interface { Commit() error Rollback() error RollbackUnlessCommitted() InsertBySql(query string, value ...interface{}) InsertStmt InsertInto(table string) InsertStmt Select(column ...string) SelectStmt DeleteFrom(table string) DeleteStmt }
Tx represents the interface to handle transaction.