What do I lose by not passing relational IDs to Ember Data?

The project I’m working on has a lot of data. For a given Promotion there have been about 1,200,000 Users. Even if I only pass the user_ids (instead of sideloading all their data), that’s around 10MB of data just for the array of IDs.

I realize that if I don’t pass the list of user_ids I won’t be able to do things like Promotion.find(1).users.find({referrer: 'none'}), but I can still do things like User.find({promotion_id: 1, referrer: 'none'}), right? Will I be losing anything else by not actually setting up relationships by passing a list of related IDs?

Hey @Kerrick

I’ve run into similar problems before and the pattern below has served me pretty well because it will continue to operate as expected with normal relationships for reading data. (I’ve done this with related models that aren’t Ember Data models).

Keep in mind: Relationship changes would have to managed manually by updating the promotionId in the User model (but that sure beats the alternative of loading an array of 1.2 million related ids). I’d be curious too if there’s any other best practices for this type of scenario:

App.Promotion = DS.Model.extend({
  users : function() {
    return App.User.find({ promotionId : this.get("id") });
  }.property("id")
});

App.User = DS.Model.extend({
  promotionId : DS.attr("number"),
  promotion : function() {
    return App.Promotion.find({ id : this.get("promotionId") });
  }.property("promotionId")
});