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

Parent models should be saved on model deletion #75

Open
igorsantos07 opened this issue May 31, 2015 · 2 comments
Open

Parent models should be saved on model deletion #75

igorsantos07 opened this issue May 31, 2015 · 2 comments

Comments

@igorsantos07
Copy link

When you remove a model that pertains to an Array of a related model, that array is updated by Ember Data but not stored unless you manually call the parent model save() method.

Currently I'm solving this issue with the following code, but I think this should be automatic?

Board = ParseModel.extend
  name:    DS.attr 'string'
  project: DS.belongsTo 'project', async: true, inverse: 'boards'

  didDelete: ->
    @get('project').then (proj)-> proj.save()
@igorsantos07
Copy link
Author

Actually, I've noticed (not sure but it seems it started happening only this night) the adapter is not removing correctly the related information.

Example:

A Post has 4 Comments.
One of those Comments is removed by its author; we call comment.destroyRecord().
That call will also remove the comment from Post.comments.
Now post.comments has only 3 models, but still wasn't persisted.
We call post.save(). The adapter will send an addUnique operation with those 3 items, but this will not remove the 4th comment from the database, creating an inconsistency.

It seems there's no register of what items were removed anymore (hasMany._deletedItems).

@igorsantos07
Copy link
Author

The issue in the last comment may be solvable by #49?

The problem in the main body is still unrelated to failing on removing data, I think.

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

1 participant