2022-08-30 02:30:36 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
const (
|
2022-09-04 03:14:19 +00:00
|
|
|
DriverSqlite3 = "sqlite3"
|
2022-08-30 02:30:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Database struct {
|
2022-09-04 03:14:19 +00:00
|
|
|
Driver string `yaml:"driver" conf:"default:sqlite3"`
|
|
|
|
SqliteUrl string `yaml:"sqlite-url" conf:"default:file:ent?mode=memory&cache=shared&_fk=1"`
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Database) GetDriver() string {
|
|
|
|
return d.Driver
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Database) GetUrl() string {
|
|
|
|
switch d.Driver {
|
|
|
|
case DriverSqlite3:
|
|
|
|
return d.SqliteUrl
|
|
|
|
default:
|
|
|
|
panic("unknown database driver")
|
|
|
|
}
|
|
|
|
}
|