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
+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