Documentation ¶
Index ¶
- type DBops
- type PgDatabase
- func (db PgDatabase) Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (db PgDatabase) BeginX(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
- func (db PgDatabase) Close()
- func (db PgDatabase) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db PgDatabase) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (db PgDatabase) GetDB() *sqlx.DB
- func (db PgDatabase) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error)
- func (db PgDatabase) NamedQuery(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
- func (db PgDatabase) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db PgDatabase) QueryRowx(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (db PgDatabase) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBops ¶
type DBops interface { Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) }
DBops dp ops
type PgDatabase ¶
type PgDatabase struct {
// contains filtered or unexported fields
}
PgDatabase struct with pg pool
func NewPostgres ¶
func NewPostgres(ctx context.Context) (*PgDatabase, error)
NewPostgres create new db
func (PgDatabase) Exec ¶
func (db PgDatabase) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec helper
func (PgDatabase) Get ¶
func (db PgDatabase) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Get helper
func (PgDatabase) NamedExec ¶
func (db PgDatabase) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error)
NamedExec helper
func (PgDatabase) NamedQuery ¶
func (db PgDatabase) NamedQuery(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
NamedQuery helper
Click to show internal directories.
Click to hide internal directories.