title: How can I use a value from one model to shape my store.query() of another?
body: <p><em>(My project is using Emberfire, which is Firebase's integration for Ember. This allows me to either make direct database calls through Firebase, or to just use the built-in model functions in Ember)</em></p>
  
  <p>I have two models. One is <code>/users</code> and contains extra information about a user(particularly their <code>schoolId</code>). The other model is <code>/schools</code> which under each id holds info such as <code>schoolName</code>/etc. I am trying to display the name of a user's school based on the <code>schoolId</code> attached to their <code>/users</code> information.</p>
  
  <p>My current approach is to use a helper called <code>school-name.js</code> in which I am using only Firebase queries to return the value:</p>
  
  <pre><code>import Ember from 'ember';
  
  export default Ember.Helper.extend({
    firebaseApp: Ember.inject.service(),
    compute(uid) {
      //Firebase Database Ref
      const database = this.get('firebaseApp').database();
      //Find the current user's schoolId
      database.ref('/users/' + uid).once('value').then(function(snapshot) {
          var schoolId = snapshot.val().schoolId;
  
          console.log("schoolId: " + schoolId);
          //Find the current user's schoolName based on their schoolId
          database.ref('/schools/' + schoolId).once('value').then(function(snapshot) {
            var schoolName = snapshot.val().schoolName;
            console.log(schoolName);
            return schoolName;
          });
      });
    }
  });
  </code></pre>
  
  <p>This will console.log the <code>schoolName</code> without a problem, but it will not display it in the template. My intuition tells me that I have to do something with Ember's and Firebase's promises system, however I have no idea where to start and the docs have not been very helpful yet.</p>
  
  <p>My previous attempt was with a mixture of Firebase and Ember's model system.</p>
  
  <pre><code>model: function() {
  
          //Get current user's uid
          const uid = this.get('session.currentUser.uid');
  
          //Inject Firebase Auth
          const auth = this.get('firebaseApp').auth();
          var user = auth.currentUser;
  
          //Inject Firebase Database
          const database = this.get('firebaseApp').database();
  
          if (user) {
              // User is signed in.
              var schoolIdRef = database.ref('/users/' + uid).once('value').then(function(snapshot) {
                  var schoolId = snapshot.val().schoolId;
                  console.log(schoolId);
                  // ...
              });
              console.log(schoolId);
              return this.store.query('schools', {
                  //Query specific school ID
                  equalTo: "0" //SET THIS TO schoolId SOMEHOW
              });
          } else {
              // No user is signed in.
          }
  
      }
  </code></pre>
  
  <p>However the template would still not load the information.
  I also made an attempt at this by using only Ember Store calls, however I did not know what to do about the fact that the query would return an array instead of a single value.</p>
  
  <p>Any help is appreciated!</p>