genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

Martin's changes

This commit is contained in:
mlabusch 2017-03-31 10:57:01 +02:00
parent 0d0d98a1d1
commit c74e2e1e85
4 changed files with 6 additions and 1 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
cmd/review/config.conf
.idea/

View File

@ -2,6 +2,7 @@ webserver_bind = ":8080"
[database]
type = "sqlite3"
# logging = true
connection = "file::memory:?mode=memory&cache=shared"
# For Master-Slave cluster
# read_connection = ""

View File

@ -20,7 +20,7 @@ func listReview(w http.ResponseWriter, r *http.Request) {
http.Error(w, "wrong productid", http.StatusNotAcceptable)
return
}
log.WithField("productid", id)
log = log.WithField("productid", id)
var list []*models.Review
result := database.Read.Where("product_id = ?", id).Find(&list)
if result.RowsAffected == 0 {

View File

@ -17,12 +17,14 @@ type Config struct {
Type string
Connection string
ReadConnection string
Logging bool
}
func Open(c Config) (err error) {
config = &c
Write, err = gorm.Open(config.Type, config.Connection)
Write.SingularTable(true)
Write.LogMode(c.Logging)
Write.Callback().Create().Remove("gorm:update_time_stamp")
Write.Callback().Update().Remove("gorm:update_time_stamp")
if err != nil {
@ -31,6 +33,7 @@ func Open(c Config) (err error) {
if len(config.ReadConnection) > 0 {
Read, err = gorm.Open(config.Type, config.ReadConnection)
Read.SingularTable(true)
Read.LogMode(c.Logging)
Read.Callback().Create().Remove("gorm:update_time_stamp")
Read.Callback().Update().Remove("gorm:update_time_stamp")
} else {