clean up scanner order and surface

This commit is contained in:
sentriz
2019-07-08 11:47:26 +01:00
parent d69d88333d
commit fd940cfc9c
2 changed files with 47 additions and 43 deletions

View File

@@ -55,6 +55,12 @@ func (db *DB) GetUserFromName(name string) *model.User {
return user
}
func (db *DB) WithTx(cb func(tx *gorm.DB)) {
tx := db.Begin()
defer tx.Commit()
cb(tx)
}
func New(path string) (*DB, error) {
pathAndArgs := fmt.Sprintf("%s?%s", path, dbOptions.Encode())
db, err := gorm.Open("sqlite3", pathAndArgs)