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

Data milestone not implemented? #32

Open
devuxer opened this issue Oct 3, 2018 · 3 comments
Open

Data milestone not implemented? #32

devuxer opened this issue Oct 3, 2018 · 3 comments

Comments

@devuxer
Copy link

devuxer commented Oct 3, 2018

The documentation mentions a milestone called data, which I believe is supposed to occur when the values of an entity are changed. I'm attempting to perform some logging of updates, and I need to know which properties of the entity have changed. Unfortunately, there appears to be no milestone between the altering of the properties and the saving of the entity. This means I'm unable to use entity.changed() (because it's either not set yet before write or already cleared after write). Am I missing something here?

EDIT

If the above is correct, it seems like the data milestone could still be implemented without any breaking changes by using this order: before fetch, after fetch, before write, before data, after data, after write. This would keep the behavior of the before write and after write the same--it would just add a couple data milestones in-between to allow some custom behavior between the properties changing and the entity being saved.

@tommybananas
Copy link
Owner

The after write milestone doesn't work for this?

@devuxer
Copy link
Author

devuxer commented Feb 5, 2019

update.write.after is too late. I can't figure out what changed if I wait until then.

I ended up using update.fetch.after because I can at least see what the original values were and compare them with the new values passed in via req.body. The problem is, I then need to perform a diff, which I had to install a special library for (object-diff).

So, having that data milestone, as I've described it above, would have greatly reduced the amount of engineering/code.

@shamoons
Copy link

Is there a big difference between using the update.fetch.after and the update.write.before? Seems the data would be the same. So why not do it in update.write.before?

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

No branches or pull requests

3 participants