mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-25 20:10:27 +00:00
Initial commit
This commit is contained in:
commit
29f583e936
135 changed files with 18463 additions and 0 deletions
27
backend/internal/config/conf_database.go
Normal file
27
backend/internal/config/conf_database.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package config
|
||||
|
||||
const (
|
||||
DriverSqlite3 = "sqlite3"
|
||||
DriverPostgres = "postgres"
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
Driver string `yaml:"driver" conf:"default:sqlite3"`
|
||||
SqliteUrl string `yaml:"sqlite-url" conf:"default:file:ent?mode=memory&cache=shared&_fk=1"`
|
||||
PostgresUrl string `yaml:"postgres-url" conf:""`
|
||||
}
|
||||
|
||||
func (d *Database) GetDriver() string {
|
||||
return d.Driver
|
||||
}
|
||||
|
||||
func (d *Database) GetUrl() string {
|
||||
switch d.Driver {
|
||||
case DriverSqlite3:
|
||||
return d.SqliteUrl
|
||||
case DriverPostgres:
|
||||
return d.PostgresUrl
|
||||
default:
|
||||
panic("unknown database driver")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue