vendredi 22 juillet 2016

Ember Data - how to fetch data without using id

I'm building an app using Ember and trying to talk to a back end API using Ember Data and writing custom adapters.

The API I am using is not RESTful or conform to JSONAPI standard. It has many endpoints that does not take in id but returns data for current user. For instance I have 'getAccountData' api that returns account data of the current user. The returned data has "id" associated with it (user_id of the current user) but you don't pass in "id" when calling the api to get the data.

I tried implementing findRecord method in my custom adapter but "id" parameter is required and it complains if I just call this.get('store').findRecord('account-data'). I can pass in dummy id like this.get('store').findRecord('account-data', 1) but this seems wrong since the 'id' of returned data won't be 1.

Should I be using findAll or query instead? is there a way to do this in clean way?




Aucun commentaire:

Enregistrer un commentaire