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.

27 lines
794 B

4 years ago
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. Items() repositories.ItemRepository
  15. }
  16. // Init gets you database based on the configuration provided.
  17. func Init(cfg config.Database) (Database, error) {
  18. switch cfg.Driver {
  19. case "bolt", "boltdb":
  20. return bolt.Init(cfg)
  21. default:
  22. return nil, &slerrors.SLError{Code: 500, Text: "Database driver " + cfg.Driver + " not recognized."}
  23. }
  24. }