Refactor repo functions to UPDATE instead of REPLACE
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user