Documentation
¶
Index ¶
- func BuildInsertStatement(tableName string, columnValues map[string]interface{}) (string, []interface{})
- func BuildUpdateStatement(tableName string, columnValues map[string]interface{}, whereColumn string, ...) (string, []interface{})
- func GetString(v interface{}, path string) string
- func IsEqualJSON(s1, s2 string) (bool, error)
- func RandomStringID() string
- func RemoveDuplicateStrings(array []string) []string
- func RunInTransaction(db *sql.DB, txFunc func(*sql.Tx) error) (err error)
- func RunStatementsInTransaction(db *sql.DB, statements []string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInsertStatement ¶
func BuildInsertStatement(tableName string, columnValues map[string]interface{}) (string, []interface{})
BuildInsertStatement is a helper function that builds an SQL INSERT statement dynamically.
func BuildUpdateStatement ¶
func BuildUpdateStatement(tableName string, columnValues map[string]interface{}, whereColumn string, whereValue interface{}) (string, []interface{})
BuildUpdateStatement is a helper function that builds an SQL UPDATE statement dynamically.
func GetString ¶
GetString lets you specify a path to the value that you want (e.g. "aaa.bbb.ccc") and have it extracted from the data structure.
func IsEqualJSON ¶
IsEqualJSON returns true if the 2 supplied strings contain JSON data that is semantically equal.
func RandomStringID ¶
func RandomStringID() string
RandomStringID returns a string of 32 characters, Each character is from the set [A-Za-z0-9].
func RemoveDuplicateStrings ¶
RemoveDuplicateStrings returns a new slice with the unique strings from the original array, i.e. duplicate elements have been removed.
func RunInTransaction ¶
RunInTransaction runs the given function inside a database transaction. Does rollback if the function returns an error or panics. Otherwise, does commit.
func RunStatementsInTransaction ¶
RunStatementsInTransaction runs all the given statements inside a database transaction. If a statement fails, the transaction is rolled back. That way either all of them take effect or none of them do.
Types ¶
This section is empty.