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.

28 lines
624 B

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. }
  17. func Open(ctx context.Context, driver string, connect string) (Database, error) {
  18. switch driver {
  19. case "postgres":
  20. return postgres.Setup(ctx, connect)
  21. default:
  22. return nil, ErrUnsupportedDriver
  23. }
  24. }