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
29 lines
671 B
package database
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"github.com/gissleh/stufflog/database/postgres"
|
|
"github.com/gissleh/stufflog/models"
|
|
)
|
|
|
|
var ErrUnsupportedDriver = errors.New("usupported driver")
|
|
|
|
type Database interface {
|
|
Goals() models.GoalRepository
|
|
Groups() models.GroupRepository
|
|
Items() models.ItemRepository
|
|
Logs() models.LogRepository
|
|
Projects() models.ProjectRepository
|
|
Tasks() models.TaskRepository
|
|
ProjectGroups() models.ProjectGroupRepository
|
|
}
|
|
|
|
func Open(ctx context.Context, driver string, connect string) (Database, error) {
|
|
switch driver {
|
|
case "postgres":
|
|
return postgres.Setup(ctx, connect)
|
|
default:
|
|
return nil, ErrUnsupportedDriver
|
|
}
|
|
}
|