accept postgres url in New

This commit is contained in:
nkanaev
2026-06-13 14:53:26 +01:00
parent 5c2d9bfc4c
commit d4766429cf

View File

@@ -1,7 +1,10 @@
package storage package storage
import ( import (
"strings"
"github.com/nkanaev/yarr/src/storage/model" "github.com/nkanaev/yarr/src/storage/model"
"github.com/nkanaev/yarr/src/storage/postgres"
"github.com/nkanaev/yarr/src/storage/sqlite" "github.com/nkanaev/yarr/src/storage/sqlite"
) )
@@ -32,5 +35,8 @@ type Storage interface {
} }
func New(path string) (Storage, error) { func New(path string) (Storage, error) {
if strings.HasPrefix(path, "postgres://") || strings.HasPrefix(path, "postgresql://") {
return postgres.New(path)
}
return sqlite.New(path) return sqlite.New(path)
} }