Documentation ¶
Overview ¶
Package mysequel provides helpers to insert data directly to database
Package mysequel provides helpers to insert data directly to database ¶
Package mysequel provides helpers to insert data directly to database
Index ¶
- func Insert(t InsertTable) (int64, error)
- func NewNullString(s string) sql.NullString
- func QueryToStructs(dest interface{}, db QueryRunner, q string, args ...interface{}) error
- func Update(t UpdateTable) (int64, error)
- type FormTable
- type InsertTable
- type QueryRunner
- type Table
- type UdpateTable
- type UpdateTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Insert ¶
func Insert(t InsertTable) (int64, error)
Insert prepares INSERT statement and executes it
func NewNullString ¶
func NewNullString(s string) sql.NullString
NewNullString fuctions returns a NULL if the passed string is empty
func QueryToStructs ¶
func QueryToStructs(dest interface{}, db QueryRunner, q string, args ...interface{}) error
QueryToStructs takes struct slice pointer, database instance, SQL query and placeholders and returns populates the slice with the result structs.
func Update ¶
func Update(t UpdateTable) (int64, error)
Update prepares UPDATE statement and executes it
Types ¶
type FormTable ¶
FormTable holds data to be inserted
func (FormTable) Transaction ¶
Transaction returns transaction object to query results from
type InsertTable ¶
type InsertTable interface { Name() string Cols() []string Values() []interface{} Transaction() *sql.Tx }
InsertTable interface define table structure perform INSERT queries
type QueryRunner ¶
QueryRunner interface allows QueryToStructs to be passed in *sql.DB and *sql.Tx instances at the same time
type Table ¶
Table holds data to be inserted
func (Table) Transaction ¶
Transaction returns transaction object to query results from
type UdpateTable ¶
type UdpateTable interface { InsertTable WhereCols() []string WhereValues() []interface{} }
UdpateTable interface define table structure perform UPDATE queries
type UpdateTable ¶
UpdateTable holds data to be updated
func (UpdateTable) WhereCols ¶
func (t UpdateTable) WhereCols() []string
WhereCols returns columns included in where clause
func (UpdateTable) WhereValues ¶
func (t UpdateTable) WhereValues() []interface{}
WhereValues returns values included in where clause