diff --git a/merp.go b/merp.go index 7f87b29..e3ad09f 100644 --- a/merp.go +++ b/merp.go @@ -11,11 +11,11 @@ import "github.com/rs/zerolog/log" import "github.com/sneak/merp/models" func thingRegex() *regexp.Regexp { - THING_REGEX, e := regexp.Compile(`^[a-zA-Z0-9\_\-]+$`) + ThingRegex, e := regexp.Compile(`^[a-zA-Z0-9\_\-]+$`) if e != nil { panic(e) } - return THING_REGEX + return ThingRegex } func decodeJson(in []byte) interface{} { diff --git a/models/db.go b/models/db.go index 0423cd6..b128ffe 100644 --- a/models/db.go +++ b/models/db.go @@ -8,17 +8,17 @@ import _ "github.com/lib/pq" var ormObject orm.Ormer -func Initialize() { +func initialize() { if os.Getenv("DEBUG") != "" { orm.Debug = true } - ConnectToDb() - SyncDB() + connectToDb() + syncDB() } // ConnectToDb - Initializes the ORM and Connection to the postgres DB -func ConnectToDb() { +func connectToDb() { orm.DefaultTimeLoc = time.UTC @@ -35,7 +35,8 @@ func ConnectToDb() { } -func SyncDB() { +// SyncDB() is responsible for creating the schema in the database +func syncDB() { // Database alias. name := "default" @@ -55,7 +56,7 @@ func SyncDB() { // GetOrmObject - Getter function for the ORM object with which we can query the database func GetOrmObject() orm.Ormer { if ormObject == nil { - Initialize() + initialize() } return ormObject } diff --git a/models/merp.go b/models/merp.go index d6e0eb4..b64d478 100644 --- a/models/merp.go +++ b/models/merp.go @@ -2,6 +2,7 @@ package models import "time" +// Merps are the primary database item in merp type Merp struct { ID int `orm:"auto;column(id)"` Content string `json:"content" orm:"type(jsonb);column(content)"`