You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
757 B
26 lines
757 B
package database
|
|
|
|
import (
|
|
"github.com/gisle/stufflog/config"
|
|
"github.com/gisle/stufflog/database/drivers/bolt"
|
|
"github.com/gisle/stufflog/database/repositories"
|
|
"github.com/gisle/stufflog/slerrors"
|
|
)
|
|
|
|
// Database is a collections of repositories.
|
|
type Database interface {
|
|
Users() repositories.UserRepository
|
|
UserSessions() repositories.UserSessionRepository
|
|
Activities() repositories.ActivityRepository
|
|
Periods() repositories.PeriodRepository
|
|
}
|
|
|
|
// Init gets you database based on the configuration provided.
|
|
func Init(cfg config.Database) (Database, error) {
|
|
switch cfg.Driver {
|
|
case "bolt", "boltdb":
|
|
return bolt.Init(cfg)
|
|
default:
|
|
return nil, &slerrors.SLError{Code: 500, Text: "Database driver " + cfg.Driver + " not recognized."}
|
|
}
|
|
}
|