How to change default findAll url

I’m doing a app that have several users, and each user hasMany mappings.

So, i’m not using JSONAPAdapter because i’m working with strongloop, so i’m using RESTAdapter with JSONSerializer.

All my mappings routes in the backend work like this:

GET        /users/{userId}/mappings
POST     /users/{userId}/mappings
PUT       /users/{userId}/mappings
DELETE /users/{userId}/mappings
GET        /users/{userId}/mappings/{mappingId}
.....

So, i want get all mappings from the logged user. How to do so? I’m trying like this:

this.store.query('mapping', {
   userId: userId
});

But doesn’t work at all. Is trying to get the data from /mappings/{userId}

Is it possible to overwrite the default findAll url? How so?

Thanks!

You can create an adapter for mapping and override urlFor.. methods. Then use like this.store.adapterFor('mapping'). ...

Correct on the first sentence. But you shouldn’t need to call the adapter manually. Instead, just do a this store.findAll(‘mapping’) and let the store pick the mapping adapter automatically

2 Likes

Yes. The point is overriding adapter urlFor... methods

1 Like

@acorncom @jmimi isn’t working. That’s how i’m trying:

export default ApplicationAdapter.extend({
  urlForFindAll(id, modelName, snapshot) {
    console.log(
      'test'
    );
  }
});

For which adapter you override? mapping or user

mapping is a model you are using

Lol, that’s some prime example of Ember support and community right there.

Community problems aside it is ridiculous how unbelievably bad Ember documentation is, there is literally none doc whatsoever on the issue. Each time I have to do something really simple, something that would take 10 minutes in React or Angular, I have to spend hours digging through the support topics, stackoverflow, and Ember docs.

To the pity souls that are still stuck with Ember — hang on there guys!

Here is the answer to original question it is actually present in API docs, though no info in the guides:

If you have questions or something isn’t clear in the docs, just ask. We iterate on them with every release.