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.

29 lines
671 B

4 years ago
4 years ago
  1. package database
  2. import (
  3. "context"
  4. "errors"
  5. "github.com/gissleh/stufflog/database/postgres"
  6. "github.com/gissleh/stufflog/models"
  7. )
  8. var ErrUnsupportedDriver = errors.New("usupported driver")
  9. type Database interface {
  10. Goals() models.GoalRepository
  11. Groups() models.GroupRepository
  12. Items() models.ItemRepository
  13. Logs() models.LogRepository
  14. Projects() models.ProjectRepository
  15. Tasks() models.TaskRepository
  16. ProjectGroups() models.ProjectGroupRepository
  17. }
  18. func Open(ctx context.Context, driver string, connect string) (Database, error) {
  19. switch driver {
  20. case "postgres":
  21. return postgres.Setup(ctx, connect)
  22. default:
  23. return nil, ErrUnsupportedDriver
  24. }
  25. }