sqlproxy

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sqlproxy is a package that provides a sql proxy for the app.

Index

Constants

View Source
const (
	// Sqlite is a constant for sqlite driver.
	Sqlite = "sqlite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBInstance

type DBInstance struct {
	FieldDB *sql.DB
}

DBInstance is a struct that implements DBInstanceInterface.

func (*DBInstance) Begin

func (d *DBInstance) Begin() (TxInstanceInterface, error)

Begin is a proxy for sql.DB.Begin.

func (*DBInstance) Close

func (d *DBInstance) Close() error

Close is a proxy for sql.DB.Close.

func (*DBInstance) Exec

func (d *DBInstance) Exec(query string, args ...interface{}) (ResultInstanceInterface, error)

Exec is a proxy for sql.DB.Exec.

func (*DBInstance) Prepare

func (d *DBInstance) Prepare(query string) (StmtInstanceInterface, error)

Prepare is a proxy for sql.DB.Prepare.

func (*DBInstance) Query

func (d *DBInstance) Query(query string, args ...interface{}) (RowsInstanceInterface, error)

Query is a proxy for sql.DB.Query.

type DBInstanceInterface

type DBInstanceInterface interface {
	Begin() (TxInstanceInterface, error)
	Close() error
	Exec(query string, args ...interface{}) (ResultInstanceInterface, error)
	Prepare(query string) (StmtInstanceInterface, error)
	Query(query string, args ...interface{}) (RowsInstanceInterface, error)
}

DBInstanceInterface is an interface for sql.DB.

type NullStringInstance

type NullStringInstance struct {
	FieldNullString *sql.NullString
}

NullStringInstance is a struct that implements NullStringInstanceInterface.

func (*NullStringInstance) Scan

func (n *NullStringInstance) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*NullStringInstance) Value

func (n *NullStringInstance) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullStringInstanceInterface

type NullStringInstanceInterface interface {
	Scan(value interface{}) error
	Value() (driver.Value, error)
}

NullStringInstanceInterface is an interface for sql.NullString.

type ResultInstance

type ResultInstance struct {
	FieldResult sql.Result
}

ResultInstance is a struct that implements ResultInstanceInterface.

func (ResultInstance) LastInsertId added in v1.1.0

func (r ResultInstance) LastInsertId() (int64, error)

LastInsertId is a proxy for sql.Result.LastInsertId.

func (ResultInstance) RowsAffected

func (r ResultInstance) RowsAffected() (int64, error)

RowsAffected is a proxy for sql.Result.RowsAffected.

type ResultInstanceInterface

type ResultInstanceInterface interface {
	LastInsertId() (int64, error)
	RowsAffected() (int64, error)
}

ResultInstanceInterface is an interface for sql.Result.

type RowInstance

type RowInstance struct {
	FieldRow *sql.Row
}

RowInstance is a struct that implements RowInstanceInterface.

func (*RowInstance) Scan

func (r *RowInstance) Scan(dest ...interface{}) error

Scan is a proxy for sql.Row.Scan.

type RowInstanceInterface

type RowInstanceInterface interface {
	Scan(dest ...interface{}) error
}

RowInstanceInterface is an interface for sql.Row.

type RowsInstance

type RowsInstance struct {
	FieldRows *sql.Rows
}

RowsInstance is a struct that implements RowsInstanceInterface.

func (*RowsInstance) Close

func (r *RowsInstance) Close() error

Close is a proxy for sql.Rows.Close.

func (*RowsInstance) Next

func (r *RowsInstance) Next() bool

Next is a proxy for sql.Rows.Next.

func (*RowsInstance) Scan

func (r *RowsInstance) Scan(dest ...any) error

Scan is a proxy for sql.Rows.Scan.

type RowsInstanceInterface

type RowsInstanceInterface interface {
	Close() error
	Next() bool
	Scan(dest ...any) error
}

RowsInstanceInterface is an interface for sql.Rows.

type Sql

type Sql interface {
	IfNullToNullString(nullStringInstance *NullStringInstance) *NullStringInstance
	Open(driverName string, dataSourceName string) (DBInstanceInterface, error)
	StringToNullString(s string) *NullStringInstance
}

Sql is an interface for sql.

func New

func New() Sql

New is a constructor for SqlProxy.

type SqlProxy

type SqlProxy struct{}

SqlProxy is a struct that implements Sql.

func (*SqlProxy) IfNullToNullString

func (*SqlProxy) IfNullToNullString(nullStringInstance *NullStringInstance) *NullStringInstance

IfNullToNullString returns a NullStringInstance if the argument is nil.

func (*SqlProxy) Open

func (*SqlProxy) Open(driverName string, dataSourceName string) (DBInstanceInterface, error)

Open is a proxy for sql.Open.

func (*SqlProxy) StringToNullString

func (*SqlProxy) StringToNullString(s string) *NullStringInstance

StringToNullString returns a NullStringInstance with the argument as the String field.

type StmtInstance

type StmtInstance struct {
	FieldStmt *sql.Stmt
}

StmtInstance is a struct that implements StmtInstanceInterface.

func (*StmtInstance) Close

func (s *StmtInstance) Close() error

Close is a proxy for sql.Stmt.Close.

func (*StmtInstance) Exec

func (s *StmtInstance) Exec(args ...interface{}) (ResultInstanceInterface, error)

func (*StmtInstance) Query

func (s *StmtInstance) Query(args ...interface{}) (RowsInstanceInterface, error)

type StmtInstanceInterface

type StmtInstanceInterface interface {
	Close() error
	Exec(args ...interface{}) (ResultInstanceInterface, error)
	Query(args ...interface{}) (RowsInstanceInterface, error)
}

StmtInstanceInterface is an interface for sql.Stmt.

type TxInstance

type TxInstance struct {
	FieldTx *sql.Tx
}

TxInstance is a struct that implements TxInstanceInterface.

func (*TxInstance) Commit

func (t *TxInstance) Commit() error

Commit is a proxy for sql.Tx.Commit.

func (*TxInstance) Exec

func (t *TxInstance) Exec(query string, args ...interface{}) (ResultInstanceInterface, error)

Exec is a proxy for sql.Tx.Exec.

func (*TxInstance) QueryRow

func (t *TxInstance) QueryRow(query string, args ...interface{}) RowInstanceInterface

QueryRow is a proxy for sql.Tx.QueryRow.

func (*TxInstance) Rollback

func (t *TxInstance) Rollback() error

Rollback is a proxy for sql.Tx.Rollback.

type TxInstanceInterface

type TxInstanceInterface interface {
	Commit() error
	Exec(query string, args ...interface{}) (ResultInstanceInterface, error)
	QueryRow(query string, args ...interface{}) RowInstanceInterface
	Rollback() error
}

TxInstanceInterface is an interface for sql.Tx.

Jump to

Keyboard shortcuts

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