I'm trying to update an app from Ember Data 1.0.0-beta.9 to 1.0.0-beta.11, and quite a bit seems to have changed. Specifically, I'm running into issues with finding out if a model instance does indeed have an associated model instance.
A = DS.Model.extend({
b: belongsTo('b', { async: true }),
});
B = DS.Model.extend({
a: belongsTo('a', { async: true }),
});
In Ember Data 1.0.0-beta.9, a.get('b')
would simply return null
if no associated model is found. That makes it easy to filter by computed property macros.
In Ember Data 1.0.0-beta.11, a.get('b')
returns a promise, which makes it much harder to use in computed property macros. If the promise is fulfilled and the content of the promise is null
, there's no associated record. But I have no idea whether it is possible to implement this check inside a Ember.computed.filter
.
I have quite a few Ember.computed.filter
s probing quite a few Ember.isEmpty(a.get('b'))
s, so I'm looking for a good way to check whether an object's async relationship is empty. Am I missing something obvious, like a built-in Ember Data api call? How would you implement such a check, if you need to filter by associated property presence/absence?