I used findAll function to access join api as below
this.store.findAll('target-ticket',{reload:true});
when I update/add record it will reflect correctly in the store.
but when I delete the record from db manually, I found the store didn't reflect correctly, the deleted record still exists in the store.
below is the case:
when I first load the app, the app loaded 4 records

after I manually delete one record from db, and trigger findAll function again,
the adapter shows that it returns 3 records, but the promiseArray still shows 4 records,


my ember-data version is 2.4, does anyone encounter the same issue? I found there is same issue before, but seems not updated. if anyone has solution, please help me. Thanks
What did you do to manually delete the record from the store?
This might be silly but was the $E variable you're using in the console there created before you removed the record from the store?
@wingkong1978 store.findAll() will make an API call and return a live updating array which contains all the models _locally_ in the store. If only a subset of the records are returned for a second call to findAll() - like when records have been deleted from the server as in your example - then the array returned for store.findAll() will still contain the "deleted" records, since they haven't been explicitly unloaded from the local store.
This behavior might be confusing at first, but auto-unloading records which aren't returned within a call to findAll() could lead to unexpected behavior: what if the app shows a record in a template and given record has been deleted on the server?
There is no easy default behavior ember-data should have here, since every application might handle this case differently.
In your case you could use a store.query("target-ticket", {}) instead: the resulting array is not live updating and will only contain the records returned for that particular API call.
Does that answer your question?
Thank you very much ~ I will make a try.
Johnny Zheng 郑永强
From: Clemens Müller
Date: 2016-08-17 00:14
To: emberjs/data
CC: wingkong1978; Mention
Subject: Re: [emberjs/data] findAll still found the record deleted from server (#4491)
@wingkong1978 store.findAll() will make an API call and return a live updating array which contains all the models locally in the store. If only a subset of the records are returned for a second call to findAll() - like when records have been deleted from the server as in your example - then the array returned for store.findAll() will still contain the "deleted" records, since they haven't been explicitly unloaded from the local store.
This behavior might be confusing at first, but auto-unloading records which aren't returned within a call to findAll() could lead to unexpected behavior: what if the app shows a record in a template and given record has been deleted on the server?
There is no easy default behavior ember-data should have here, since every application might handle this case differently.
In your case you could use a store.query("target-ticket", {}) instead: the resulting array is not live updating and will only contain the records returned for that particular API call.
Does that answer your question?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@wingkong1978 I am closing this issue as I think your use case is solved when using store.query(…). Feel free to reopen if you think there is still an issue; or ask on the #-ember-data slack channel if you have further questions. Thanks!
@pangratz just ran into this same issue. I agree auto-unloading server-deleted records is likely problematic, but it seems like it might make sense to ED to at least flag records that are still loaded in the store, but weren't in the results of a fresh findAll() call. Right now it's not clear how to best handle filtering out of server-deleted records when pulling in updates
From the server after a delete to a 'sometable' table row I send a notification to other users via websocket.
ws.sendDataToAllOtherUsers(req, {'meta':{'delete','type':'sometable','id':id}});
On the client side the basic functioning is similar to
wsMessage(event) {
var json=JSON.parse(event.data);
if (json.meta && json.meta.delete ) {
this.get('store').peekRecord(json.meta.type, json.meta.type).deleteRecord();
} else {
this.get('store').pushPayload(json);
}
}
add your own error checking
@nsharrok that works in cases that you have control over the server and are receiving updates over websockets, but in the general case of just loading the most-recent list of records when entering a route (or with either manual refreshes or automatic polling), it still seems like there should be _some_ way to discover that a record wasn't included in the most recent findAll() result
Most helpful comment
@pangratz just ran into this same issue. I agree auto-unloading server-deleted records is likely problematic, but it seems like it might make sense to ED to at least flag records that are still loaded in the store, but weren't in the results of a fresh
findAll()call. Right now it's not clear how to best handle filtering out of server-deleted records when pulling in updates