Refactor repo functions to UPDATE instead of REPLACE

This commit is contained in:
Denis Arh
2019-07-23 07:08:14 +02:00
parent 8a5ca66fce
commit 84ed53f429
5 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ func (r chart) Create(mod *types.Chart) (*types.Chart, error) {
func (r chart) Update(mod *types.Chart) (*types.Chart, error) {
now := time.Now().Truncate(time.Second)
mod.UpdatedAt = &now
return mod, r.db().Replace(r.table(), mod)
return mod, r.db().Update(r.table(), mod, "id")
}
func (r chart) DeleteByID(namespaceID, chartID uint64) error {
+1 -1
View File
@@ -112,7 +112,7 @@ func (r *namespace) Update(mod *types.Namespace) (*types.Namespace, error) {
now := time.Now()
mod.UpdatedAt = &now
return mod, r.db().Replace(r.table(), mod)
return mod, r.db().Update(r.table(), mod, "id")
}
func (r *namespace) DeleteByID(namespaceID uint64) error {
+1 -1
View File
@@ -173,7 +173,7 @@ func (r page) Update(mod *types.Page) (*types.Page, error) {
now := time.Now().Truncate(time.Second)
mod.UpdatedAt = &now
return mod, r.db().Replace(r.table(), mod)
return mod, r.db().Update(r.table(), mod, "id")
}
func (r page) DeleteByID(namespaceID, pageID uint64) error {
+1 -1
View File
@@ -260,7 +260,7 @@ func (r record) Create(record *types.Record) (*types.Record, error) {
}
func (r record) Update(record *types.Record) (*types.Record, error) {
if err := r.db().Replace("compose_record", record); err != nil {
if err := r.db().Update("compose_record", record, "id"); err != nil {
return nil, errors.Wrap(err, "could not update record")
}
+1 -1
View File
@@ -110,7 +110,7 @@ func (r trigger) Create(mod *types.Trigger) (*types.Trigger, error) {
func (r trigger) Update(mod *types.Trigger) (*types.Trigger, error) {
now := time.Now().Truncate(time.Second)
mod.UpdatedAt = &now
return mod, r.db().Replace(r.table(), mod)
return mod, r.db().Update(r.table(), mod, "id")
}
func (r trigger) DeleteByID(namespaceID, triggerID uint64) error {