ember-parse-adapter
ember-parse-adapter copied to clipboard
Parent models should be saved on model deletion
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()
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 fromPost.comments
. Nowpost.comments
has only 3 models, but still wasn't persisted. We callpost.save()
. The adapter will send anaddUnique
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
).
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.