Currently, I only know of the way to lookup a single instance through owner.lookup('model:user')
. What I want is to be able to get all for the model type. Is there an API for that?
@rmmmp Are you working on an integration test or an acceptance test?
You could use the store to get all the users.
let store = this.owner.lookup('service:store');
let users = store.peekAll('user');
Nope. I’m working on an addon. Changing my examples for a bit, let’s say I want to iterate on all services available in my app. this.owner.lookup('service:store')
only returns the storr service.
Anyways, I don’t think I’ll be needing this approach anymore. But would still like to know if an API is available just in case.
There’s not an owner API for this. There is private API for enumerating all the registered modules, which is enough to find all the services, etc. Try
Object.keys(requirejs.entries)
.filter(name => /your-app-name\/services/.test(name));
2 Likes