36 lines
671 B
Go
36 lines
671 B
Go
package storage
|
|
|
|
import (
|
|
"github.com/glebarez/sqlite"
|
|
"gorm.io/driver/postgres"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Storage struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewStorageSqlite(filePath string) (*Storage, error) {
|
|
db, err := gorm.Open(sqlite.Open(filePath))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Storage{
|
|
db: db,
|
|
}, nil
|
|
}
|
|
|
|
func NewStoragePostgres(dbUrl string) (*Storage, error) {
|
|
db, err := gorm.Open(postgres.Open(dbUrl))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Storage{
|
|
db: db,
|
|
}, nil
|
|
}
|
|
|
|
// TODO: Placeholder. Update to proper implementation later. Including signature
|
|
func (s *Storage) FindLocalAccount(handle string) (string, error) {
|
|
return handle, nil
|
|
}
|