-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Relationships and Changesets #551
Comments
pinging @snewcomer @jaredgalanis @rwwagner90 since you've talked about these issues recently, happy to hear your thoughts on this! |
@sandstrom I think we would need to see the operations (in a code example) you are looking to take on the changeset. I think we can help you on that.
This is the beauty of the Proxy. We can trap at any level. In this case, every level now has a |
@snewcomer Sounds great! 😄 🎉 I've looked at the diff and I understand some of it, but far from everything. Since there are no documentation, a few quick questions:
Also, what are your thoughts about adding/removing relationships to/from a model (or adding/removing from an array)? |
Adding and removing from an array will also be quite difficult. Atomically replacing the array is really the only sane way to do it, especially when dealing with ember-data array like objects. We trap the setter but don't trap array methods like push/concat. |
@snewcomer Thanks for taking time answering! One idea could be to extend the basic principle of the changeset to relationships. It's already a proxy at the key/value surface of an object, basically get/set is proxied and buffered. But this "leaks" is if One approach would be to "tell" the changeset, when initiated, about the keys that return relationships, for example
Happy to clarify my thinking about this and explain in more detail! |
@sandstrom That is an interesting idea. I like it. I'll see if I can put up a psuedo RFC at some point in the next few weeks. |
@snewcomer Sounds great! Happy to help flesh out the idea, if you want? Just wanted to hear your overall thoughts on the idea first (to avoid spending time on something that is unlikely to bear fruit), but it sounds likely you are at least cautiously positive at this point. |
@sandstrom and @snewcomer, just to confirm your instincts on this; I would also find this feature very useful. I work around it by creating my own |
Plus one on this. I don't find the way |
When working with changesets, this pattern is quite common:
What I'd like to do here is to make changes to the address instances and buffer them inside a changeset. So that I can do rollback on the model and automatically have rollbacks applied to all child changesets too.
Maybe by specifying which relationships should create proxy changesets and buffer, e.g.
let model = Changeset(user, validator, { nested: ['addresses'] });
or similar (opt-in).Right now changesets seems to support access via keys, e.g.
changeset.set('profile.url', '…')
but notchangeset.get('profile').set('url', '…')
Has there been any discussion on supporting relationships, such that the handlebars example above would work with rollback/save on the user, with changes applied to nested addresses?
Would also be good to support rollback/apply for changes to the collection itself, i.e. adding/removing addresses. Maybe via an API such as
model.get('addresses').add(vacationHome);
wheremodel.get('addresses')
would return an instance of e.g.ChangeSetList
.Related issues:
mergeDeep
with your data. Are you trying to merge two ember-data objects? #543The text was updated successfully, but these errors were encountered: