Best practices for loading singular/singleton resources with Ember Data?


#1

I have been writing a few Ember-based apps and frequently I face the situation where I need to load a singular resource, such as general metadata for the application (e.g. /metadata).

I searched through forums, stackoverflow, etc but I cannot find what is the way to go when attempting to accomplish this seemingly simple use case with Ember Data so I could have the API benefits, caching, etc.

Can it be done with Ember data at all? What is the community approach to this and are there best practices when dealing with this scenario?


#2

Did you every find an ideal scenario? I’ve searched around and haven’t found a conclusive answer. I’m building a class management system and I would like something like /courses/:id/gradebook.


#3

Unfortunately, the answer seems to be “not supported”.

So I’m having to resort to old-school jQuery ajax calls for these scenarios… this is a road block for systems that need this a lot. Very basic use case. I hope this gets some attention before 1.0, but who knows…


#4

I think the general approach is to just get the first, only object returned after a .find() or such. Eg;

this.store.find('foobar').then(function(foobars){ 
    return foobars.get('firstObject'); 
});