Documentation ¶
Index ¶
- func BuildInsert(tableName string, obj interface{}) string
- func BuildUpdate(tableName string, obj interface{}) string
- func Exec(query string, args ...interface{}) (sql.Result, error)
- func ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func Get(dest interface{}, query string, args ...interface{}) error
- func GetArguments(s interface{}) []interface{}
- func GetArgumentsForUpdate(s interface{}) []interface{}
- func Query(query string, args ...interface{}) (*sql.Rows, error)
- func QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func QueryRow(query string, args ...interface{}) *sql.Row
- func QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func Select(dest interface{}, query string, args ...interface{}) error
- type IntBool
- type NullBool
- type NullFloat64
- type NullInt64
- type NullString
- type NullTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInsert ¶
BuildInsert creates an insert query for given table name and accompanying struct returning a query string with placeholders ? for mysql
func BuildUpdate ¶
BuildUpdate creates an update query for given table name and accompanying struct returning a query string with placeholders ? for mysql
func Exec ¶
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.
func ExecContext ¶
ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.
func GetArguments ¶
func GetArguments(s interface{}) []interface{}
GetArguments receives a struct and puts the struct values into an array so that it can be passed into a query
func GetArgumentsForUpdate ¶
func GetArgumentsForUpdate(s interface{}) []interface{}
GetArgumentsForUpdate receives a struct and puts the struct values into an array so that it can be passed into a query
func Query ¶
Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func QueryContext ¶
QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func QueryRow ¶
QueryRow executes a query that is expected to return at most one row. QueryRow always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.
func QueryRowContext ¶
QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.
Types ¶
type IntBool ¶
IntBool is a type wrapper for tinyint columns used as bools
func (IntBool) MarshalJSON ¶
MarshalJSON converts the value to null or JSON bool
func (*IntBool) UnmarshalJSON ¶
UnmarshalJSON converts 1, 0, true, false to bool value from JSON or nil on null
type NullBool ¶
NullBool is a wrapper for sql.NullBool for JSON methods to remove Valid
func (*NullBool) MarshalJSON ¶
MarshalJSON converts the value to null or JSON bool
type NullFloat64 ¶
type NullFloat64 struct {
sql.NullFloat64
}
NullFloat64 is a wrapper for sql.NullFLoat64 for JSON methods to remove Valid
func (NullFloat64) MarshalJSON ¶
func (n NullFloat64) MarshalJSON() ([]byte, error)
MarshalJSON converts the value to null or JSON float
func (NullFloat64) String ¶
func (n NullFloat64) String() string
type NullInt64 ¶
NullInt64 is a wrapper for sql.NullInt64 for JSON methods to remove Valid
func (NullInt64) MarshalJSON ¶
MarshalJSON converts the value to null or JSON int
type NullString ¶
type NullString struct {
sql.NullString
}
NullString is a wrapper for sql.NullString for JSON methods to remove Valid
func ToNullString ¶
func ToNullString(value string, setValidOnEmpty bool) NullString
func (NullString) MarshalJSON ¶
func (n NullString) MarshalJSON() ([]byte, error)
MarshalJSON converts the value to null or JSON string
func (*NullString) Scan ¶
func (ns *NullString) Scan(value interface{}) error
Scan implements the Scanner interface for NullString
type NullTime ¶
NullTime is a wrapper for mysql.NullTime for JSON methods to remove Valid
func (NullTime) MarshalJSON ¶
MarshalJSON converts the value to null or JSON time