goqu: github.com/doug-martin/goqu/exec Index | Files

package exec

import "github.com/doug-martin/goqu/exec"

Index

Package Files

query_executor.go query_factory.go scanner.go

type DbExecutor Uses

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 Uses

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

func (QueryExecutor) Exec Uses

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

func (QueryExecutor) ExecContext Uses

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

func (QueryExecutor) Query Uses

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

func (QueryExecutor) QueryContext Uses

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

func (QueryExecutor) ScanStruct Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

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

func (QueryExecutor) ScannerContext Uses

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 Uses

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

type QueryFactory Uses

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

func NewQueryFactory Uses

func NewQueryFactory(de DbExecutor) QueryFactory

type Scanner Uses

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 Uses

func NewScanner(rows *sql.Rows) Scanner

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

Package exec imports 7 packages (graph). Updated 2020-03-26. Refresh now. Tools for package owners.