Documentation ¶
Index ¶
- type DbExecutor
- type QueryExecutor
- func (q QueryExecutor) Exec() (gsql.Result, error)
- func (q QueryExecutor) ExecContext(ctx context.Context) (gsql.Result, error)
- func (q QueryExecutor) Query() (*gsql.Rows, error)
- func (q QueryExecutor) QueryContext(ctx context.Context) (*gsql.Rows, error)
- func (q QueryExecutor) ScanStruct(i interface{}) (bool, error)
- func (q QueryExecutor) ScanStructContext(ctx context.Context, i interface{}) (bool, error)
- func (q QueryExecutor) ScanStructs(i interface{}) error
- func (q QueryExecutor) ScanStructsContext(ctx context.Context, i interface{}) error
- func (q QueryExecutor) ScanVal(i interface{}) (bool, error)
- func (q QueryExecutor) ScanValContext(ctx context.Context, i interface{}) (bool, error)
- func (q QueryExecutor) ScanVals(i interface{}) error
- func (q QueryExecutor) ScanValsContext(ctx context.Context, i interface{}) error
- func (q QueryExecutor) Scanner() (Scanner, error)
- func (q QueryExecutor) ScannerContext(ctx context.Context) (Scanner, error)
- func (q QueryExecutor) ToSQL() (sql string, args []interface{}, err error)
- type QueryFactory
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbExecutor ¶
type QueryExecutor ¶
type QueryExecutor struct {
// contains filtered or unexported fields
}
func (QueryExecutor) ExecContext ¶
func (QueryExecutor) QueryContext ¶
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