# Model vs. Promise Comparison

**URL:** <https://discuss.emberjs.com/t/model-vs-promise-comparison/11002>\
**Category:** Ember Data\
**Created:** [June 25, 2016, 6:56am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002 "2016-06-25T06:56:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmuehlberger](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mmuehlberger/32/12402_2.png) [@mmuehlberger](https://discuss.emberjs.com/u/mmuehlberger)\
**Post date:** [June 25, 2016, 6:56am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002/1 "2016-06-25T06:56:35Z")

</div>

Promises are used very transparently in Ember. Normally you can use a promise just like a model, which is great!

When using comparison however, it gets tricky. When you compare a promise with a model you don’t get a match even if they are equal.

In my case, I have to check if an object is already in an arrays, which sometimes return Promises and sometimes the actual objects. The comparison is done with `.contains()`. When I do direct comparison with `===`, I can try fetching the `content` property to see if I got a promise and have two checks, which is tedious but it works, with arrays it isn’t so simple anymore.

How did you solve this issue?

---

<div class="post-metadata">

**Author:** ![jmimi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jmimi/32/11507_2.png) [@jmimi](https://discuss.emberjs.com/u/jmimi)\
**Post date:** [June 25, 2016, 8:58am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002/2 "2016-06-25T08:58:48Z")

</div>

What do you mean from “sometimes return Promises and sometimes the actual objects”?

---

<div class="post-metadata">

**Author:** ![mmuehlberger](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mmuehlberger/32/12402_2.png) [@mmuehlberger](https://discuss.emberjs.com/u/mmuehlberger)\
**Post date:** [June 25, 2016, 9:20am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002/3 "2016-06-25T09:20:47Z")

</div>

Yes, I should clarify that, sorry.

I’m having a component that does some elaborate selection. Depending on where it is used in the app, it sometimes received a PromiseArray with actual Ember Data Models, and sometimes an Array of Promise objects of the same type of Data Models.

To add another form of equality check, that doesn’t work with Promises: `Ember.isEqual`.

---

<div class="post-metadata">

**Author:** ![jmimi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jmimi/32/11507_2.png) [@jmimi](https://discuss.emberjs.com/u/jmimi)\
**Post date:** [June 25, 2016, 9:54am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002/4 "2016-06-25T09:54:20Z")

</div>

I think you should handle this in upper layer. It’s better component deals with one type of input

---

<div class="post-metadata">

**Author:** ![mmuehlberger](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mmuehlberger/32/12402_2.png) [@mmuehlberger](https://discuss.emberjs.com/u/mmuehlberger)\
**Post date:** [June 27, 2016, 8:03am UTC](https://discuss.emberjs.com/t/model-vs-promise-comparison/11002/5 "2016-06-27T08:03:26Z")

</div>

Thanks, I figured that might be the only solutions. I just hoped, that since Promises are so transparent that there would be a more elegant solution to this.
