I’m looking for some guidance on how to go about modeling record counts/totals at a global level within my application, not quite sure the best, most efficient way to go about it within ember-data.
A good example to illustrate what I’m looking for is to take an e-mail client that has a sidebar with links to the main boxes/folders, e.g. Inbox, Spam, Drafts, Sent, ect, and next to each one is a badge with the total number of messages in that folder. Now given a
Message model, of which there may be thousands of instances contained within each of these different folders, you obviously don’t want to have to fetch all of them from the server, in order to get the necessary
total meta data in which to render out each folder’s count. Also, any filtering/searching that the user does within each folder should not affect these “global” totals.
Given these requirements, and assuming I have complete control over the backend API, how would you go about retreiving and displaying this count information? My first thought was maybe to have a
Count model, that was fetched separately from the main records, which had an attribute for each of the “folders” (i.e.
folder2Count, ect.). However I’m not quite sure this is the best possible solution, as it seems I would have to make sure this
Count model was always being manually reloaded/refreshed throughout my application code, whenever a change occurred that might change the values.