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

View File

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

View File

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