Documentation ¶
Index ¶
- func OpenDB(cfg Config) (*pgxpool.Pool, error)
- type Config
- type DBTX
- type KeyTransaction
- type PGStore
- func (p *PGStore) Begin(ctx context.Context) (pgx.Tx, error)
- func (p *PGStore) Commit(ctx context.Context) error
- func (p *PGStore) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
- func (p *PGStore) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
- func (p *PGStore) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (p *PGStore) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (p *PGStore) Rollback(ctx context.Context) error
- type TxManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBTX ¶
type DBTX interface { Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row Begin(ctx context.Context) (pgx.Tx, error) Commit(ctx context.Context) error Rollback(ctx context.Context) error }
DBTX adalah interface yang mengabstraksi operasi database, baik operasi biasa maupun operasi dalam transaksi. isi daripada interface ini tergantung driver database yang dipakai misalnya saya menggunakan pgxpool. maka kita akan meniru semua fungsi2nya
func NewPGStore ¶
NewPGStore return interface can execute TX and pgx.Pool
type PGStore ¶
func (*PGStore) Exec ¶
func (p *PGStore) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
Exec implements DBTX
func (*PGStore) Prepare ¶
func (p *PGStore) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
Prepare implements DBTX
Click to show internal directories.
Click to hide internal directories.