1

I have a device model, which has one (belongsTo) an ingest model.

Elsewhere in my app, I have a device loaded, and need to know if the device has an ingest present on it. I check it like this:

return this.get('device.ingest') === null;

By calling device.ingest, Ember automatically issues an AJAX request to .find('ingest', device.ingest.id). I really just want to know if it's there or not, I don't want to fetch it.

How can I do this?

Sam Selikoff
  • 11,238
  • 9
  • 54
  • 94
  • possible duplicate of [Get belongsTo ID without fetching record](http://stackoverflow.com/questions/20479179/get-belongsto-id-without-fetching-record) –  Sep 12 '14 at 13:49

2 Answers2

1

It's a bit ugly, but you could access to private property of the model: this.get('device')._data.ingest === undefined or this.get('device')._data.ingest_id === undefined (depends of your naming system).

Microfed
  • 2,432
  • 19
  • 25
1

shouldn't this simply work for you?

return this.get('device.data.ingest.id') === null /* or undefined */;
code-jaff
  • 8,472
  • 4
  • 30
  • 52