# findByAttribute inside ObjectController

**URL:** https://discuss.emberjs.com/t/findbyattribute-inside-objectcontroller/3366
**Category:** Ember Data
**Created:** [November 16, 2013, 5:17pm UTC](https://discuss.emberjs.com/t/findbyattribute-inside-objectcontroller/3366 "2013-11-16T17:17:45Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![balint](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/balint/32/12521_2.png) [@balint](https://discuss.emberjs.com/u/balint)
#### Post date: [November 17, 2013, 12:38pm UTC](https://discuss.emberjs.com/t/findbyattribute-inside-objectcontroller/3366/4 "2013-11-17T12:38:42Z")

</div>

A couple of quibbles.

1. I would use `orders` as the name of the variable with the response data: `order.get("firstObject")` is weird to read. Expanding on that, if sequence numbers serve as ids in your app, I think there is a way to set that up as primary key with ember-data. That would make more clearer.

2. 

> [@rezakhadjavi](#):
>
> The rest of my delivered action runs before the function inside the .then() block does so if I need to do anything with info retrieved from this query, it better be inside the then() block!

I would probably put everything inside the resolved branch (so inside the `then(function(order) { ... })`, otherwise some changes that the code outside it cause might happen before what’s inside and that’s probably not what you want.

1. 

> [@rezakhadjavi](#):
>
> that.transitionToRoute(“order”, next\_id);

Quoting [the Ember Doctor proposal](http://discuss.emberjs.com/t/dr-ember-doctor-tool-for-diagnosing-improving-ember-apps/3338/2):

> [@Dr. Ember Doctor: tool for diagnosing/improving Ember Apps](https://discuss.emberjs.com/t/dr-ember-doctor-tool-for-diagnosing-improving-ember-apps/3338/2):
>
> Calling `transitionToRoute` is generally discouraged; it might make more sense for you to move this action into a Route

---

_[View the full topic](https://discuss.emberjs.com/t/findbyattribute-inside-objectcontroller/3366)._
