在StartDate和EndDate上进行Firestore查询

时间:2018-10-31 10:32:04

标签: javascript angularjs typescript firebase ionic-framework

我正在使用Ionic和Firestore作为数据库来开发应用程序。

我存储餐厅的菜单,每个菜单都有一个StartDate和EndDate。我只想显示当天的菜单。

我知道Firebase不允许在不同字段上使用带有范围过滤器的查询,但是有办法吗?

这是不允许的:

this.menuCollection = this.afs.collection<any>('Menu', ref => ref.where('StartDate', '<=', this.today).where('EndDate', '>=', this.today));
this.menuObs = this.menuCollection.valueChanges();

我尝试过:

this.menuCollection = this.afs.collection<any>('Menu', ref => ref.where('StartDate', '<=', this.today));
this.menuCollection.ref.where('EndDate', '>=', this.today);
this.menuObs = this.menuCollection.valueChanges();

但是在那种情况下,它不会执行第二个查询(带有EndDate的查询)。

非常感谢您的回答!

0 个答案:

没有答案
相关问题