How to perform compound queries with logical OR in Cloud Firestore?

后端 未结 9 1676
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 02:07

From the docs:

You can also chain multiple where() methods to create more specific queries (logical AND).

How can I perform an <

9条回答
  •  悲哀的现实
    2020-11-22 02:36

    you can bind two Observables using the rxjs merge operator. Here you have an example.

    import { Observable } from 'rxjs/Observable';
    import 'rxjs/add/observable/merge';
    
    ...
    
    getCombinatedStatus(): Observable {
       return Observable.merge(this.db.collection('foo', ref => ref.where('status','==','open')).valueChanges(),
                               this.db.collection('foo', ref => ref.where('status','==','upcoming')).valueChanges());
    }
    

    Then you can subscribe to the new Observable updates using the above method:

    getCombinatedStatus.subscribe(results => console.log(results);
    

    I hope this can help you, greetings from Chile!!

提交回复
热议问题