genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] add database support

This commit is contained in:
Martin Geno 2017-03-30 16:16:19 +02:00
parent 75a378a0cd
commit eb75db5989
3 changed files with 4 additions and 11 deletions

View File

@ -1,16 +1,14 @@
package database package database
import ( import (
"errors"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite" _ "github.com/jinzhu/gorm/dialects/sqlite"
_ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/postgres"
) )
var ( var (
Write *gorm.Database Write *gorm.DB
Read *gorm.Database Read *gorm.DB
config *Config config *Config
models []interface{} models []interface{}
) )
@ -22,7 +20,7 @@ type Config struct {
ReadConnection string ReadConnection string
} }
func Open(c Config) (err errors.Error) { func Open(c Config) (err error) {
config = &c config = &c
Write, err = gorm.Open(config.Type, config.Connection) Write, err = gorm.Open(config.Type, config.Connection)
if err != nil { if err != nil {

View File

@ -1,3 +1,2 @@
package database package database

View File

@ -12,11 +12,7 @@ import (
//Config the config File of this daemon //Config the config File of this daemon
type Config struct { type Config struct {
WebserverBind string WebserverBind string
Database struct { Database database.Config
Type string
Connection string
ReadConnection string
}
} }
// ReadConfigFile reads a config model from path of a yml file // ReadConfigFile reads a config model from path of a yml file