database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMySQL = "mysql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Type() string
	Connect(ctx context.Context) error
	Ping(ctx context.Context) error
	WithinTransaction(ctx context.Context, txCallback func(ctx context.Context) error) error
}

type MySQL

type MySQL struct {
	SQL
	Config config.MySQLConfig
}

func NewMySQL

func NewMySQL(config config.MySQLConfig) *MySQL

func (*MySQL) Connect

func (ds *MySQL) Connect(ctx context.Context) error

func (MySQL) Ping

func (ds MySQL) Ping(ctx context.Context) error

func (MySQL) Type

func (ds MySQL) Type() string

type NullString

type NullString struct {
	sql.NullString
}

NullString type representing a nullable string

func StringToNullString

func StringToNullString(str *string) NullString

func (NullString) MarshalJSON

func (s NullString) MarshalJSON() ([]byte, error)

MarshalJSON returns the marshaled json string

func (*NullString) UnmarshalJSON

func (s *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON returns the unmarshaled struct

type NullTime

type NullTime struct {
	sql.NullTime
}

NullTime type representing a nullable string

func (NullTime) MarshalJSON

func (t NullTime) MarshalJSON() ([]byte, error)

MarshalJSON returns the marshaled json string

type SQL

type SQL struct {
	DB *sqlx.DB
}

func (SQL) ExecContext

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

func (SQL) GetContext

func (ds SQL) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (SQL) NamedExecContext

func (ds SQL) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)

func (SQL) PrepareContext

func (ds SQL) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (SQL) QueryContext

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

func (SQL) QueryRowContext

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

func (SQL) SelectContext

func (ds SQL) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (SQL) WithinTransaction

func (ds SQL) WithinTransaction(ctx context.Context, txFunc func(ctx context.Context) error) error

type SQLRepository

type SQLRepository struct {
	DB *SQL
}

SQLRepository type

func NewSQLRepository

func NewSQLRepository(db *SQL) SQLRepository

NewSQLRepository returns an instance of SQLRepository

type SqlQueryable

type SqlQueryable interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

type SqlTx

type SqlTx struct {
	Tx *sqlx.Tx
}

func (SqlTx) ExecContext

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

func (SqlTx) GetContext

func (q SqlTx) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (SqlTx) NamedExecContext

func (q SqlTx) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)

func (SqlTx) PrepareContext

func (q SqlTx) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (SqlTx) QueryContext

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

func (SqlTx) QueryRowContext

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

func (SqlTx) SelectContext

func (q SqlTx) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Jump to

Keyboard shortcuts

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