3
0

upd(vendor): update factory db with MustGet()

This commit is contained in:
Tit Petric
2018-07-17 18:09:13 +02:00
parent 65a458eab2
commit a1cccd23d3
2 changed files with 10 additions and 1 deletions
Generated
+1 -1
View File
@@ -93,7 +93,7 @@
".",
"resputil"
]
revision = "48ba0357b31ad368f66fa2441bd23c12757c56a0"
revision = "382da457432419256cfbcf8806efcc1470adb60f"
[[projects]]
branch = "master"
+9
View File
@@ -131,6 +131,15 @@ func (r *DatabaseFactory) Get(dbName ...string) (*DB, error) {
return nil, fmt.Errorf("No configuration found for database: %v", names)
}
// MustGet is the same as Get, except it will panic on connection error
func (r *DatabaseFactory) MustGet(dbName ...string) *DB {
db, err := r.Get(dbName...)
if err != nil {
panic(err)
}
return db
}
// DB struct encapsulates sqlx.DB to add new functions
type DB struct {
*sqlx.DB