exec

package
v9.10.2-0...-7114063 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbExecutor

type DbExecutor interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

type QueryExecutor

type QueryExecutor struct {
	// contains filtered or unexported fields
}

func (QueryExecutor) Exec

func (q QueryExecutor) Exec() (gsql.Result, error)

func (QueryExecutor) ExecContext

func (q QueryExecutor) ExecContext(ctx context.Context) (gsql.Result, error)

func (QueryExecutor) Query

func (q QueryExecutor) Query() (*gsql.Rows, error)

func (QueryExecutor) QueryContext

func (q QueryExecutor) QueryContext(ctx context.Context) (*gsql.Rows, error)

func (QueryExecutor) ScanStruct

func (q QueryExecutor) ScanStruct(i interface{}) (bool, error)

This will execute the SQL and fill out the struct with the fields returned. This method returns a boolean value that is false if no record was found

var myStruct MyStruct
found, err := db.From("test").Limit(1).ScanStruct(&myStruct)
if err != nil{
    panic(err.Error()
}
if !found{
      fmt.Println("NOT FOUND")
}

i: A pointer to a struct

func (QueryExecutor) ScanStructContext

func (q QueryExecutor) ScanStructContext(ctx context.Context, i interface{}) (bool, error)

This will execute the SQL and fill out the struct with the fields returned. This method returns a boolean value that is false if no record was found

var myStruct MyStruct
found, err := db.From("test").Limit(1).ScanStructContext(ctx, &myStruct)
if err != nil{
    panic(err.Error()
}
if !found{
      fmt.Println("NOT FOUND")
}

i: A pointer to a struct

func (QueryExecutor) ScanStructs

func (q QueryExecutor) ScanStructs(i interface{}) error

This will execute the SQL and append results to the slice

var myStructs []MyStruct
if err := db.From("test").ScanStructs(&myStructs); err != nil{
    panic(err.Error()
}
//use your structs

i: A pointer to a slice of structs.

func (QueryExecutor) ScanStructsContext

func (q QueryExecutor) ScanStructsContext(ctx context.Context, i interface{}) error

This will execute the SQL and append results to the slice

var myStructs []MyStruct
if err := db.From("test").ScanStructsContext(ctx, &myStructs); err != nil{
    panic(err.Error()
}
//use your structs

i: A pointer to a slice of structs.

func (QueryExecutor) ScanVal

func (q QueryExecutor) ScanVal(i interface{}) (bool, error)

This will execute the SQL and set the value of the primitive. This method will return false if no record is found.

 var id uint32
 found, err := db.From("test").Select("id").Limit(1).ScanVal(&id)
 if err != nil{
     panic(err.Error()
 }
 if !found{
     fmt.Println("NOT FOUND")
 }

i: Takes a pointer to a primitive value.

func (QueryExecutor) ScanValContext

func (q QueryExecutor) ScanValContext(ctx context.Context, i interface{}) (bool, error)

This will execute the SQL and set the value of the primitive. This method will return false if no record is found.

 var id uint32
 found, err := db.From("test").Select("id").Limit(1).ScanValContext(ctx, &id)
 if err != nil{
     panic(err.Error()
 }
 if !found{
     fmt.Println("NOT FOUND")
 }

i: Takes a pointer to a primitive value.

func (QueryExecutor) ScanVals

func (q QueryExecutor) ScanVals(i interface{}) error

This will execute the SQL and append results to the slice.

var ids []uint32
if err := db.From("test").Select("id").ScanVals(&ids); err != nil{
    panic(err.Error()
}

i: Takes a pointer to a slice of primitive values.

func (QueryExecutor) ScanValsContext

func (q QueryExecutor) ScanValsContext(ctx context.Context, i interface{}) error

This will execute the SQL and append results to the slice.

var ids []uint32
if err := db.From("test").Select("id").ScanValsContext(ctx, &ids); err != nil{
    panic(err.Error()
}

i: Takes a pointer to a slice of primitive values.

func (QueryExecutor) Scanner

func (q QueryExecutor) Scanner() (Scanner, error)

Scanner will return a Scanner that can be used for manually scanning rows.

func (QueryExecutor) ScannerContext

func (q QueryExecutor) ScannerContext(ctx context.Context) (Scanner, error)

ScannerContext will return a Scanner that can be used for manually scanning rows.

func (QueryExecutor) ToSQL

func (q QueryExecutor) ToSQL() (sql string, args []interface{}, err error)

type QueryFactory

type QueryFactory interface {
	FromSQL(sql string, args ...interface{}) QueryExecutor
	FromSQLBuilder(b sb.SQLBuilder) QueryExecutor
}

func NewQueryFactory

func NewQueryFactory(de DbExecutor) QueryFactory

type Scanner

type Scanner interface {
	Next() bool
	ScanStruct(i interface{}) error
	ScanVal(i interface{}) error
	Close() error
	Err() error
}

Scanner knows how to scan sql.Rows into structs.

func NewScanner

func NewScanner(rows *sql.Rows) Scanner

NewScanner returns a scanner that can be used for scanning rows into structs.

Jump to

Keyboard shortcuts

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