-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapter Should Allow For Meta-Results #124
Comments
How would you feel about loading metadata in a |
I am fine with that. As far as storing the meta information is concerned, I currently attach it to the model array itself. Because I am trying to keep all this inside the adapter, this restricts metadata to the findQuery method as I am not given access to the model array inside findAll. Another thought I have is that there might be some utility in allowing custom model array implementations: e.g. PaginatedModelArray etc. |
@ghempton Seems like you could do this in your adapter. If you need some hooks could you submit a PR? |
What's the current thinking on this? I'm currently doing as @ghempton mentioned and overriding There appears to be some support for the |
+1. Metadata makes sense. Guys, have you got a temp workaround? |
When I attach |
👍 - Can we please have this re-evaluated. |
Currently facing @christophermanning issue as well... edit: Gotten around it by overwriting didFindQuery in my adapter: didFindQuery: function(store, type, payload, recordArray) {
var loader = DS.loaderFor(store);
loader.populateArray = function(data) {
recordArray.load(data);
// This adds the meta property returned from the server
// onto the recordArray sent back
recordArray.set('meta', payload.meta);
};
this.get('serializer').extractMany(loader, payload, type);
} |
I think the use case where you want to store metainformation of a query is pretty common and worth looking into it. The solution @christophermanning is proposing sounds clean enough; why not have it implemented on the Adapter by default? |
Since the #815 has been merged, does it solve it as well ? |
The issue I had with the recordArray solution above is that if you execute a If you take a look at #815, it should solve these issues (it was specifically designed for this, as I had a need to send pagination data back from the server). There is a quick explanation of how it works with the ticket, but I am happy to create more in-depth examples if someone can suggest where I should place them, as we are yet to have ember-data docs. |
Currently, RestAdapter expects everything in the returned JSON to correspond to model data. This is even more strictly enforced with the introduction of side-loading.
An extremely common scenario, however, is for the server to return metadata associated with the query, e.g. aggregate counts, pagination info, etc. The ability to capture this information is also the first step for features such as pagination.
The text was updated successfully, but these errors were encountered: