Requesting Data without Embedding IDs

I have an app resource that is loaded with the route /apps/1. I’d like to display some metrics about the app, so I created the route:

  this.resource("apps", function() {
    this.route('show', { path: ':app_id' }, function() {
      this.resource('metrics', function() { });

I’m confused at how to get the app to call the metrics api endpoint. I’ve tried doing:

  model: function() {
    return this.modelFor('apps/show').get('metrics');


  metrics: DS.hasMany('metric', {async: true}),

But my understanding is because there are no embedded IDs to metrics in the show response from the server, ember data doesn’t know what to request. The metrics resource is kind of loosey-goosey. It’s returning data that’ll be use to build a graph for visualization.

Is there a way to NOT embed IDs and still get ember to always request the additional data on the /metrics endpoint?

There is a way you can generate a unique guid for each metric. In the serializer for metric, you could employ the following method:

  normalize: function(typeClass, hash, prop) {
    hash['id'] = Ember.generateGuid(null, 'metric');
    return this._super(typeClass, hash, prop);

It is a private API, i.e. could change or be removed at anytime. Ember - 4.6 - Ember API Documentation

I ended up putting a links object in the API response and that satisfied the use case. I made up a an ID on the API side. Thanks for the insight! I didn’t know about that function :smile: