db

package
v0.2.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db DB) error

func Connect

func Connect(db DB) error

func MigrateDown

func MigrateDown(database *sql.DB, logger logger.Logger, files fs.FS)

func MigrateFixDown

func MigrateFixDown(database *sql.DB, logger logger.Logger, files fs.FS, ver int)

func MigrateFixUp

func MigrateFixUp(database *sql.DB, logger logger.Logger, files fs.FS, ver int)

func MigrateUp

func MigrateUp(database *sql.DB, logger logger.Logger, files fs.FS)

func NewPostgresDB

func NewPostgresDB(logger logger.Logger) (*sql.DB, error)

Types

type DB

type DB interface {
	Close() error
	Ping() error
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Prepare(query string) (*sql.Stmt, error)
	Begin() (*sql.Tx, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

type DBLogger

type DBLogger struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDBLogger

func NewDBLogger(db *sql.DB, logger logger.Logger) DBLogger

func (DBLogger) Begin

func (d DBLogger) Begin() (*sql.Tx, error)

func (DBLogger) Close

func (d DBLogger) Close() error

func (DBLogger) Exec

func (d DBLogger) Exec(query string, args ...interface{}) (sql.Result, error)

func (DBLogger) ExecContext

func (d DBLogger) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (DBLogger) Ping

func (d DBLogger) Ping() error

func (DBLogger) Prepare

func (d DBLogger) Prepare(query string) (*sql.Stmt, error)

func (DBLogger) PrepareContext

func (d DBLogger) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (DBLogger) Query

func (d DBLogger) Query(query string, args ...interface{}) (*sql.Rows, error)

func (DBLogger) QueryContext

func (d DBLogger) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (DBLogger) QueryRow

func (d DBLogger) QueryRow(query string, args ...interface{}) *sql.Row

func (DBLogger) QueryRowContext

func (d DBLogger) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

type PostgresListener

type PostgresListener struct {
	Callbacks map[string]func(data string)
	Listener  *pq.Listener
	// contains filtered or unexported fields
}

func NewPostgresListner

func NewPostgresListner(logger logger.Logger) *PostgresListener

func (*PostgresListener) Close

func (p *PostgresListener) Close()

func (*PostgresListener) Listen

func (p *PostgresListener) Listen(channel string, callback func(data string))

func (*PostgresListener) Ping

func (p *PostgresListener) Ping()

func (*PostgresListener) Start

func (p *PostgresListener) Start()

func (*PostgresListener) Unlisten

func (p *PostgresListener) Unlisten(channel string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL