Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change tracking for updates #57

Open
bencrouse opened this issue Dec 10, 2021 · 2 comments · May be fixed by #56
Open

Change tracking for updates #57

bencrouse opened this issue Dec 10, 2021 · 2 comments · May be fixed by #56
Assignees

Comments

@bencrouse
Copy link

Is your feature request related to a problem? Please describe.
When saving an update to a model, the entire document is overwritten in the database, as opposed to only the fields that have changed, which could open you up to concurrency issues. Tracking changes can also be useful when implementing something like audit log.

Describe the solution you'd like
An update that only $sets the changed fields and a function API (e.g. model.HasChanged("FieldName")) to check what fields have changed in the hooks.

Describe alternatives you've considered
I'm not sure how this could implemented without changes to mgm, but open to ideas for sure!

Additional context
Would you all be open to a PR to add this if I put some work into it?

@mehran-prs
Copy link
Member

Hi @bencrouse
Tracking changes in models could be a little be complicated.
I think the more simple solution for concurrency issues could be MongoDB transactions and optimistic locks which will be added after merging PR #56

@bencrouse
Copy link
Author

Ok I didn't see that PR, which will certainly solve for the concurrency concern, thank you!

@mehran-prs mehran-prs linked a pull request Dec 13, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants