title: Firebase get all usernames & user Id starting with user entered character
body: <p>I am trying to only fetch username and user IDs that only start with the User entered text.</p>
  
  <p>Below is my firebase database:</p>
  
  <p><a href="https://i.stack.imgur.com/UWs8B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UWs8B.png" alt="My Firebase Database"></a></p>
  
  <p>As you can see the database contains a list of user Ids which contains the username. </p>
  
  <blockquote>
    <p>For Example:  If the user enters M in the search box, Query should
    <strong>return Mr Jois and it's the corresponding user ID.</strong></p>
  </blockquote>
  
  <p>I am trying to do this using javascript. Below is my code:</p>
  
  <pre><code>function* searchUsers(action) {
      const database = firebase.database();
      const ref = database.ref('users');
      try {
          console.log('about to fetch filters users');
          const query = ref.orderByChild('username').startAt(action.searchText);
          const snapshot = yield call([query, query.once], 'value');
          console.log('done fetching users');
          console.log(snapshot);
      }
      catch(error){
          console.log(error);
      }
  }
  </code></pre>
  
  <p>But I am not getting the expected results. Can someone please tell me how to query the result to get the expected result?</p>