How to remove a model during the didFindAll callback?


I have a situation where my app gets loaded with a basic model (based on configuration).

ie- when the app loads I generate a “pseudo model” / “placeholder” for each foo

  name: 'start',
  initialize: function() {
    $.getJSON("/api/foo"),then(function(json) {
      var store = DS.get('defaultStore');
      var transaction = store.transaction();
      App.Foo.add(json, transaction);
    }, function(error) {

Then later in the application, when I actually want to show a list of “foo”, I do a find to query for them.


It’s at this point where I need a special “hook” to remove the models given some unique value and replace them with the incoming model (when it exists)

I’m doing this outside of ember data today and it’s not pretty. I’m curious if a hook like this exists in ember-data or if it should/could in the near future?

(right now I’m doing something like this in the find)

find: function() {
  $.getJSON('/api/findByDate/', function(response) {
    //for loop over each item in the response
      //inner for loop over each "foo" item in the array
        item.replace(index, x); //x being the # to replace

This approach works for me but it feels like ember-data should support “configuration” based replacements. I think a lot of software as a service apps are based on configuration and would benefit from something like this (as they could load up a global configuration to start with, then modify that object graph later).

Anyone have advice / done this in an existing app? / think ember-data should support this?