title: EmberJS Processing before returning model
body: <p>How can one do processing on an ember model before returning it in the hook? I currently have something along the following lines in a route</p>
  
  <pre><code>model: function (params) {
          var list_of_modelAs = [];
  
          this.store.find('modelA').then(function (modelAs) {
              modelAs.forEach ( function (modelA) {
                  modelA.get('modelB').then(function(modelB) {
                      if (modelB.get('id') == params.modelB_id) {
                          list_of_modelAs.push(modelA)
                      }
                  })
              })
          });
  
          return list_of_modelAs;
      }
  </code></pre>
  
  <p>Where modelA and modelB of course are models defined with Ember-Data.</p>
  
  <p>I'm essentially creating an array of models but filtering them first. Really what I want to do is just filter the array of models, but I couldn't figure out another way to do it as <code>modelB</code> is a foreign model (<code>modelA</code> belongsTo <code>modelB</code>, i.e. each modelA has a modelB). Ideally what I'm trying to do is something like:</p>
  
  <p><code>return this.store.find('modelA', where modelA.modelB.id = someValue)</code></p>
  
  <p>The problem is, of course, that because of promises and such, only an empty <code>list_of_modelAs</code> is returned and the model comes up empty. </p>
  
  <p>I assume I have to somehow structure this to return a promise from the model hook, but I'm not quite sure how.</p>