title: Firebase query not returning results everytime it runs
body: <p>I have implemented a search function in an angular 7 app that uses Firebase. I want the user to provide a from and to values always and a date value optionally. At the moment whenever a user provides all 3 values (from, to &amp; date) the query returns the expected result. But if only from &amp; to values are provided, the query returns expected result sometimes and doesn't at other times. I haven't been able to find a bug in my code so I need you guys to help look at my code to see if I am doing something wrong. Here's my code</p>
  
  <p>schedule.service.ts</p>
  
  <pre><code>searchSchedulesList(route: string, date) {
  let now = this.formatDate(this.today);
  
  if (date != null) {
    return this.afs
      .collection("schedules", ref =&gt;
        ref
          .where("route", "==", route)
          .where("date", "==", date)
          .where("date", "&gt;=", now)
          .orderBy("date", "asc")
          .orderBy("time", "asc")
      )
      .snapshotChanges();
  } else {
    return this.afs
      .collection("schedules", ref =&gt; ref.where("route", "==", route))
      .snapshotChanges();
  }
  }
  </code></pre>
  
  <p>schedule.component.ts</p>
  
  <pre><code>search(route: string, date) {
  this.scheduleService.searchSchedulesList(route, date).subscribe(data =&gt; {
    this.schedules = data.map(e =&gt; {
      return {
        id: e.payload.doc.id,
        ...e.payload.doc.data()
      } as Schedule;
    });
  });
  </code></pre>
  
  <p>}</p>
  
  <p>This is the search form used to get the values <code>from</code> <code>to</code> and <code>date</code></p>
  
  <pre><code>&lt;form [formGroup]="searchForm"&gt;
    &lt;div class="row"&gt;
      &lt;div class="form-group col-3"&gt;
        &lt;select formControlName="from" id="from" class="form-control"&gt;
          &lt;option value=""&gt;From&lt;/option&gt;
          &lt;option
            *ngFor="let destination of destinations"
            value="{{ destination.abbreviation }}"
            &gt;{{ destination.fullname }}&lt;/option
          &gt;
        &lt;/select&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group col-3"&gt;
        &lt;select formControlName="to" id="to" class="form-control"&gt;
          &lt;option value=""&gt;To&lt;/option&gt;
          &lt;option
            *ngFor="let destination of destinations"
            value="{{ destination.abbreviation }}"
            &gt;{{ destination.fullname }}&lt;/option
          &gt;
        &lt;/select&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group col-3"&gt;
        &lt;input formControlName="date" type="date" class="form-control" /&gt;
      &lt;/div&gt;
  
      &lt;div class="col-3"&gt;
        &lt;button
          class="btn btn-primary btn-sm"
          (click)="
            search(
              searchForm.value.from + searchForm.value.to,
              searchForm.value.date
            )
          "
        &gt;
          Search
        &lt;/button&gt;
  
        &lt;button class="btn btn-secondary btn-sm" (click)="clear()"&gt;
          Reset
        &lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>