27 lines
778 B
Go
27 lines
778 B
Go
package repository
|
|
|
|
import (
|
|
"errors"
|
|
"git.dragon-labs.de/alphyron/group_helper/config"
|
|
"git.dragon-labs.de/alphyron/group_helper/logic"
|
|
"git.dragon-labs.de/alphyron/group_helper/repository/sql"
|
|
)
|
|
|
|
func NewUserHelperRepository() (logic.GroupHelperRepository, error) {
|
|
databaseConfig := config.DatabaseConfig{}
|
|
_ = databaseConfig.LoadConfig()
|
|
|
|
switch databaseConfig.DatabaseType {
|
|
case "mysql":
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
case "postgres":
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
case "sqlite3":
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
case "mssql":
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
}
|
|
|
|
return nil, errors.New("cannot support given database type (" + databaseConfig.DatabaseType + ")")
|
|
}
|