Plan stuff. Log stuff.
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

4 years ago
  1. package database
  2. import (
  3. "github.com/gisle/stufflog/config"
  4. "github.com/gisle/stufflog/database/drivers/bolt"
  5. "github.com/gisle/stufflog/database/repositories"
  6. "github.com/gisle/stufflog/slerrors"
  7. )
  8. // Database is a collections of repositories.
  9. type Database interface {
  10. Users() repositories.UserRepository
  11. UserSessions() repositories.UserSessionRepository
  12. Activities() repositories.ActivityRepository
  13. Periods() repositories.PeriodRepository
  14. }
  15. // Init gets you database based on the configuration provided.
  16. func Init(cfg config.Database) (Database, error) {
  17. switch cfg.Driver {
  18. case "bolt", "boltdb":
  19. return bolt.Init(cfg)
  20. default:
  21. return nil, &slerrors.SLError{Code: 500, Text: "Database driver " + cfg.Driver + " not recognized."}
  22. }
  23. }