Start refactoring

This commit is contained in:
Aurélie Delhaie
2023-05-29 17:44:50 +02:00
parent 55ac50f3be
commit c06843cd28
31 changed files with 1125 additions and 1267 deletions

View File

@@ -0,0 +1,30 @@
package pgsql
import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"opensavecloudserver/data/datasource"
)
type (
DatabaseDatasource struct {
conn *gorm.DB
}
)
func NewDatabaseDatasource() datasource.Datasource {
return new(DatabaseDatasource)
}
func (dd *DatabaseDatasource) Connect(dsn string) error {
conn, err := gorm.Open(postgres.Open(dsn))
if err != nil {
return err
}
dd.conn = conn
return nil
}
func (dd *DatabaseDatasource) DB() *gorm.DB {
return dd.conn
}