Commit f2101eae authored by Shane O'Neill's avatar Shane O'Neill

Added interface for DbMap and getter methods for Db and Dbx attributes

parent 1d22fc0d
......@@ -21,6 +21,38 @@ import (
type DbIM interface {
GetDb() *sql.DB
GetDbx() *sqlx.DB
NewDbMap(db *sql.DB, dialect Dialect) *DbMap
TraceOn(prefix string, logger *log.Logger)
AddTable(i interface{}, name ...string) *TableMap
AddTableWithName(i interface{}, name string) *TableMap
CreateTablesSql() (map[string]string, error)
CreateTables() error
CreateTablesIfNotExists() error
writeColumnSql(sql *bytes.Buffer, table *TableMap, col *ColumnMap)
createTables(ifNotExists, exec bool) (map[string]string, error)
DropTables() error
Insert(list ...interface{}) error
Update(list ...interface{}) (int64, error)
Delete(list ...interface{}) (int64, error)
Get(dest interface{}, keys ...interface{}) error
Select(i interface{}, query string, args ...interface{}) error
Exec(query string, args ...interface{}) (sql.Result, error)
Begin() (*Transaction, error)
TableFor(i interface{}) *TableMap
TableForType(t reflect.Type) *TableMap
TruncateTables() error
TruncateTablesIdentityRestart() error
truncateTables(restartIdentity bool) error
queryRow(query string, args ...interface{}) *sql.Row
queryRowx(query string, args ...interface{}) *sqlx.Row
query(query string, args ...interface{}) (*sql.Rows, error)
trace(query string, args ...interface{})
// TableNameMapper is the function used by AddTable to map struct names to database table names, in analogy
// to sqlx.NameMapper which does the same for struct field name to database column names.
var TableNameMapper = strings.ToLower
......@@ -52,6 +84,14 @@ func NewDbMap(db *sql.DB, dialect Dialect) *DbMap {
return &DbMap{Db: db, Dialect: dialect, Dbx: sqlx.NewDb(db, dialect.DriverName())}
func (m *DbMap) GetDb() *sql.DB {
return Db
func (m *DbMap) GetDbx() *sqlx.Dbx {
return Dbx
// TraceOn turns on SQL statement logging for this DbMap. After this is
// called, all SQL statements will be sent to the logger. If prefix is
// a non-empty string, it will be written to the front of all logged
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment