Skip to content

Commit

Permalink
Handle list updates correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcook committed Jan 26, 2023
1 parent 0736e60 commit a96c134
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ func updateInternal(id string, ptr interface{}, opts *UpdateOptions) error {
return fmt.Errorf("can't set unknown field '%s'", tagName)
}
case reflect.Slice:
// Delete old list before adding new entries
pip.Del(ctx, prefix+":"+id+":"+k)

for i := 0; i < structField.Len(); i++ {
if !structField.Index(i).Elem().FieldByName("Base").IsZero() {
itemID := structField.Index(i).Elem().FieldByName("Base").FieldByName("ID").String()
Expand Down

0 comments on commit a96c134

Please sign in to comment.