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."} } }