Hello,
What would be the best way to update an object and at the same time let the backend know about an additional operation that it should do?
For example: I want to update the email of a User object.
user.email = 'newEmail@domain.com';
user.save();
When the backend sees that the email has been updated, it must additionally send an email address to the user notifying him of the change. But the email must be sent only when the email field changes, not other fields.
I could make an initial query in the database and then for each field in the user table, figure out what changed. But if I have a lot of fields, code on the backend gets messy.
I would prefer something like the following:
user.email = 'newEmail@domain.com';
var meta = {operation: 'changeEmail'};
user.save(meta);
Now there’s a way to tell the backend exactly which fields have changed and it will know to make additional operations if needed.
Is there any way to do this? Do you think this addition to Ember Data makes sense?
I’ve seen other people ask something similar on StackOverflow, but this solution doesn’t work with the latest Ember Data anymore.
Thanks!