No template update after creating Record with findQuery

I am wondering why my template is not updating after createRecord

when used findQuery

to fetch data.

Changing this return this.store.findQuery('timetracking', {year: year, month: month, user_id: user_id});

to the return this.store.find('timetracking');

template is updated with my new entries.

I don't want to fetch all records to save bandwidth, but when used find/findQuery

with query parameters only, my newly created records don't show up in my template.

Do I need to reload "force"? How do you do it?

Update

The Ember inspector shows new entries.

+3


source to share


1 answer


findQuery

puts the task of filtering back on the server. Ember Data assumes that the results that were returned are the only results associated with this collection. find

no query or id ( findAll

) will always return all records found in the store because it understands that you weren't looking for any filtered set, if you create a new record, it happily knows to include it in all available records. You can manually write an entry to a collection of entries using pushObject

.



// assuming you're in the context of your `findQuery` results, and they are the model
var model = this.get('model'),
    record = this.store.createRecord('timetracking', {...});

model.pushObject(record);

      

+5


source







All Articles