Documentation ¶
Index ¶
- type Database
- func (d *Database) Begin(ctx context.Context, t ReplicaType) (pgx.Tx, error)
- func (d *Database) BeginFunc(ctx context.Context, t ReplicaType, f func(pgx.Tx) error) error
- func (d *Database) BeginTx(ctx context.Context, t ReplicaType, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (d *Database) BeginTxFunc(ctx context.Context, t ReplicaType, txOptions pgx.TxOptions, ...) error
- func (d *Database) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (d *Database) GetReplica(t ReplicaType) *Replica
- func (d *Database) Migrate(source migration.Source, direction migration.Direction, max int) (int, error)
- func (d *Database) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (d *Database) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, ...) (pgconn.CommandTag, error)
- func (d *Database) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (d *Database) SelectAll(ctx context.Context, dest interface{}, sql string, args ...interface{}) error
- func (d *Database) SelectOne(ctx context.Context, dest interface{}, sql string, args ...interface{}) error
- func (d *Database) SendBatch(ctx context.Context, t ReplicaType, b *pgx.Batch) pgx.BatchResults
- type Entity
- type Replica
- type ReplicaType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a database replicas pool.
func (*Database) Begin ¶
func (d *Database) Begin(ctx context.Context, t ReplicaType) (pgx.Tx, error)
func (*Database) BeginTx ¶
func (d *Database) BeginTx(ctx context.Context, t ReplicaType, txOptions pgx.TxOptions) (pgx.Tx, error)
func (*Database) BeginTxFunc ¶
func (*Database) Exec ¶
func (d *Database) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
Exec executes a non-SELECT query using an RW replica.
func (*Database) GetReplica ¶
func (d *Database) GetReplica(t ReplicaType) *Replica
GetReplica returns a next replica of type t from a pool.
func (*Database) SelectAll ¶
func (d *Database) SelectAll(ctx context.Context, dest interface{}, sql string, args ...interface{}) error
SelectAll performs a SELECT query and scans all rows into a slice of structs or maps.
type Entity ¶
type Entity struct { ID uint UUID pgtype.UUID CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp DeletedAt pgtype.Timestamp }
func (*Entity) GetCreatedAt ¶
func (*Entity) GetDeletedAt ¶
func (*Entity) GetUpdatedAt ¶
type Replica ¶
type Replica struct { DSN string Type ReplicaType // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.