findQuery and pushPayload

I’m running into an issue with findQuery on a controller store. The query works fine, but when I pushPayload on to the store, it isn’t triggering any sort of change, and isn’t updating. If I change to findAll, then pushPayload works as expected.

Old code (works):

model: function(params) {
    return this.store.findAll('my-model');
},

then later:

controller.store.pushPayload('my-model', data);

But if I switch to:

model: function(params) {
    return this.store.findQuery('my-model', params);
},

then later:

controller.store.pushPayload('my-model', data);

Then the update isn’t triggered. Any thoughts? I read that findQuery is returning something different than findAll, but, I’m not sure if there’s a way around it or not.

Hi @jpohlmann!

findAll and query (findQuery has been deprecated in 1.13) return different things in the sense that findAll return a live array that will be updated when adding/changing/removing records of the same type to the store.

The result from query does simply not live-update.

My coworker actually ended up finding a solution for this. If you add a filter to your store, then it brings back a live array. So adding:

return this.store.filter('my-model', function(post) {
    return true;
});

Will correct this problem. Also, you can add in any new filtering options you want as well.

Thank you for this solution @jpohlmann. Worked flawlessly for me.