Replacing an associated list on update #6621
Unanswered
johannes-riecken
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to replace an object in the database with the new one provided as function argument. In this example, each
Pet
has an associated list ofTag
s, but when I run.Save
, the newTag
s simply get appended. What's the recommended approach here? Should I add that approach as a section to gorm.io's pages/docs/update.md once I know about it?For the example code below the actual output is:
ID: 1
Tags: [foo bar]
Whereas the desired output would be:
ID: 1
Tags: [bar]
Beta Was this translation helpful? Give feedback.
All reactions