Documentation
¶
Index ¶
- Variables
- type Handler
- type QueryStruct
- type Request
- func (rq Request) ExecQuery(args ...interface{}) (sql.Result, error)
- func (rq Request) GetFields(args ...interface{}) error
- func (rq Request) GetIntoOneStruct(args ...interface{}) error
- func (rq Request) GetIntoSlice(args ...interface{}) error
- func (rq Request) GetIntoStructs(args ...interface{}) error
- func (rq Request) GetOneField(args ...interface{}) error
- func (rq Request) GetOneRow(args ...interface{}) (*sql.Row, error)
- func (rq Request) GetRows(args ...interface{}) (*sql.Rows, error)
- func (rq Request) InsertOneStruct(structure interface{}) error
- func (rq Request) InsertStructs(slice interface{}) error
- func (rq Request) PrepareStmt() (*sql.Stmt, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoArg = errors.New("no passed argument, can not scan")
ErrNoArg is for functions that should scan rows but have no passed argument
Functions ¶
This section is empty.
Types ¶
type QueryStruct ¶
type QueryStruct struct {
Query string // full Query string
Statement string // statement part of query
Table string // targeted table of query
Set string // optionnal set parameter of query
Condition string // optionnal condition of query
}
QueryStruct is a structure used to concatenate queries
func (QueryStruct) String ¶
func (q QueryStruct) String() string
String returns a Query string from QueryStruct. If the Query field is not empty, it is returned, else a concatenation of other fields is returned
type Request ¶
type Request struct {
Handler // might be *sql.Tx or *sql.DB
QueryStruct // Query structure
Arg interface{} // for scan functions
}
Request is used to prepare (and optionnaly make) queries via Handler (which can be *sql.DB or *sql.Tx), during or outside transactions.
func FromHandler ¶
FromHandler returns an initialized Request with given Handler (*Tx or *DB)
func (Request) ExecQuery ¶
ExecQuery prepares and makes a query which does not need to return any row
func (Request) GetFields ¶
GetFields prepares and makes a query, retrieves a Row, and scan it into a slice of any pointers. Should be used for queries selecting multiple fields from a single row
func (Request) GetIntoOneStruct ¶
GetIntoOneStruct prepares and makes a query, retrieves a Row, and scan it into a pointer to one struct. Should be used for queries selecting multiple fields from a single row (if this query is unique, consider using GetFields instead)
func (Request) GetIntoSlice ¶
GetIntoSlice prepares and makes a query, retrieves Rows, and scan them into a pointer to a slice of any type. Should be used for queries selecting one field from multiple rows
func (Request) GetIntoStructs ¶
GetIntoStructs prepares and makes a query, retrieves Rows, and scan them into a pointer to a slice of structures. Should be used for queries selecting multiple fields from multiple rows
func (Request) GetOneField ¶
GetOneField prepares and makes a query, retrieves a Row, and scan it into the passed pointer. Should be used for queries selecting one field from one row
func (Request) InsertOneStruct ¶
InsertOneStruct inserts one structure into the given table. Can insert sub structures, if they have the tag `req:"include"`
func (Request) InsertStructs ¶
InsertStructs inserts a slice of structures into the given table. Can insert sub structures, if they have the tag `req:"include"`