I am working on optimizing my backend json api. The biggest bottleneck is serializing all the relationship ids. I have had success using the links option and generating links like “posts/:post_id/comments” or “comments?post_id=:post_id”. But I don’t think it is optimal to have the backend serialize the url in cases where the url is obvious.
I would like to extend ember-data to build the url automatically when the relationship is asynchronous. All the info needed is available or could be customized by adding options like ‘foreign_key’, ‘primary_key’ to the hasMany definition.
On a related note I am also thinking of extending the reload method to append the a timestamp to the request so the backend could return just the objects that have changed. This might be better implemented in the controller, but just a thought.
Reloading a relationship would do something like:
var query = {this.foreign_key: this.id, updated_after: this.max_timestamp}
this.store.filter( 'comment', query , function(record){
return record.get(this.foreign_key) == this.id;
});
Regarding the url has any one done anything similar? Is this something that should be considered being built in?