Documentation ¶
Index ¶
- Variables
- func CopyInterface(destValue reflect.Value, src interface{}) error
- func FieldByPath(v reflect.Value, name string) (reflect.Value, error)
- func InsertRecord(db *sqlx.DB, tableName string, record interface{}) (sql.Result, error)
- func Marshall(source interface{}, dest interface{}) error
- func MarshallInsertRecord(db *sqlx.DB, table string, data interface{}, dbTemplate interface{}) (resID int64, err error)
- func MarshallUpdateRecord(db *sqlx.DB, table string, data interface{}, dbTemplate interface{}) (resID int64, err error)
- func Query(db *sqlx.DB, query string, dbTemplate interface{}, data interface{}, ...) (err error)
- func UnMarshall(source interface{}, dest interface{}) error
- func UpdateRecord(db *sqlx.DB, tableName string, record interface{}) (sql.Result, error)
- func VerifySQLTableName(tableName string) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrBadTableName = errors.New("The table name inputted does not contain legal characters")
ErrBadTableName used in case of illegal characters in the table definition in GetTableLength
Functions ¶
func CopyInterface ¶
CopyInterface is a copy of convertAssign from the sql package It copies a value from a src to a destination interface converting types as appropriate. Ideally we would want to have this interface exported.. but the Powers-that-be decided to keep it private so we have to clone it here.
func FieldByPath ¶
FieldByPath returns the struct field with the given path It returns the zero Value if no field was found. Note that if there is no period in the name then this is exactly the same as FieldMyName (except it doesn't panic)
func InsertRecord ¶
InsertRecord allows you to insert a new record into a table respecting nulls
func Marshall ¶
func Marshall(source interface{}, dest interface{}) error
Marshall copies the values to a database structure from an internal representation structure using the annotations on the database structure to indicate which field to copy to. This maps null fields from the database (stored in the sql.NullString... structures) into an appropriate null value.
func MarshallInsertRecord ¶
func MarshallInsertRecord(db *sqlx.DB, table string, data interface{}, dbTemplate interface{}) (resID int64, err error)
MarshallInsertRecord inserts a record of any type into the database and returns the insertId from that record if it succeeds or any errors if it fails For the dbTemplate you must pass in an empty structure by address to allow the data to be marshalled
func MarshallUpdateRecord ¶
func MarshallUpdateRecord(db *sqlx.DB, table string, data interface{}, dbTemplate interface{}) (resID int64, err error)
MarshallUpdateRecord finds the record based on the table name and the autoIncrementing key. NOTE: Whatever structure is inserted into the table, the incrementing key must be the ONLY incrementing key in the table and it must be the same as the record you are hoping to update
func Query ¶
func Query(db *sqlx.DB, query string, dbTemplate interface{}, data interface{}, args ...interface{}) (err error)
Query executes a query on the database for a single record into a database template and then marshalls the result into a data interface. If no records are found for the query, sql.ErrNoRows is returned
func UnMarshall ¶
func UnMarshall(source interface{}, dest interface{}) error
UnMarshall copies the values from a database structure into an internal representation structure using the annotations on the database structure to indicate which field to copy to. This maps null fields from the database (stored in the sql.NullString... structures) into an appropriate null value.
func UpdateRecord ¶
UpdateRecord allows you to update an existing record in the database
func VerifySQLTableName ¶
VerifySQLTableName checks for potential SQL injection errors by confirming that the table name does not contain anything but alpha numeric and underscore characters
Types ¶
This section is empty.