Martin's changes
This commit is contained in:
parent
0d0d98a1d1
commit
c74e2e1e85
|
@ -1 +1,2 @@
|
|||
cmd/review/config.conf
|
||||
.idea/
|
||||
|
|
|
@ -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 = ""
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Reference in New Issue