Model find does not detect deleted records?


#1

For a simple overview screen I have a route that sets up a controller that does an App.Location.find(). I naively assumed that this would simply go to the store and fetch me all the records, giving me an up-to-date view of the records.

Apparently not…

  • When an external process starts removing records from the database, the App.Location.find() keeps on returning these deleted records. (although the REST call doesn’t show them anymore)
  • If an external process starts adding records to the database, the App.Location.find() picks them up.
  • If I delete the records form within the Ember app itself the model is correctly updated.

How should I deal with this in my Ember app ? I’d like to have an up-to-date view on whatever is in my database. Right now I need to refresh the page (F5) to get an up to date view. Using the linkTo helpers shows me the stale data.

This seems to be yet another trivial thing that I completely missed in EmberJS. Is it somewhere mentioned in the docs why it behaves like that ? I guess there is a valid philosophy behind this behavior.

My overview screens is simply interested in showing the most up-to-date data. If a record is no longer in the DB the model should not return it anymore.

Posted this question on SO as well : http://stackoverflow.com/questions/16380143/emberjs-model-find-not-up-to-date-with-underlying-store

It’s becoming increasingly more difficult to avoid utter frustration :smile:


#2

This seems to be a known issue in EmberData :


#3

This is still a problem…any progress on this.

A findAll keeps deleted records around even though the server no longer returns them.

Is there at least a way to manually clear them?


#4

Is this still an issue?

I ended added this method to my store:

	refreshRecords: function(type) {
	var currentComments = this.peekAll(type);

	this.query(type, {}).then(function(queriedComments) {
		currentComments.forEach(function(comment) {
			if (!queriedComments.includes(comment)) {
				this.unloadRecord(comment);
			}
		}.bind(this));
	}.bind(this));
}