restructure
This commit is contained in:
13
providers/database/sqlite/config.go
Executable file
13
providers/database/sqlite/config.go
Executable file
@@ -0,0 +1,13 @@
|
||||
package sqlite
|
||||
|
||||
type Config struct {
|
||||
File string
|
||||
}
|
||||
|
||||
func (m *Config) CreateDatabaseSql() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Config) EmptyDsn() string {
|
||||
return m.File
|
||||
}
|
||||
21
providers/database/sqlite/sqlite.go
Normal file
21
providers/database/sqlite/sqlite.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"github.com/rogeecn/atom/container"
|
||||
"go.uber.org/dig"
|
||||
|
||||
// "gorm.io/driver/sqlite"
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func Provide(conf *Config, opts ...dig.ProvideOption) error {
|
||||
return container.Container.Provide(func() (*gorm.DB, error) {
|
||||
db, err := gorm.Open(sqlite.Open(conf.File), &gorm.Config{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return db, err
|
||||
}, opts...)
|
||||
}
|
||||
Reference in New Issue
Block a user