Angular 角度Firestore集合查询&;订购人
我正在执行一个简单的查询,然后想按日期订购 这非常好:Angular 角度Firestore集合查询&;订购人,angular,typescript,firebase,google-cloud-firestore,Angular,Typescript,Firebase,Google Cloud Firestore,我正在执行一个简单的查询,然后想按日期订购 这非常好: this.afs.collection('orders', ref=> ref.where('orderStatus', '<', 7)); this.afs.collection('orders',ref=>ref.where('orderStatus',”Cloud Firestore要求您首先按应用范围过滤器的字段下单,然后按您选择的任何其他字段下单 参考: 可以通过为要查询的集合创建范围筛选器字段和下一个要排序的字段的
this.afs.collection('orders', ref=> ref.where('orderStatus', '<', 7));
this.afs.collection('orders',ref=>ref.where('orderStatus',”Cloud Firestore要求您首先按应用范围过滤器的字段下单,然后按您选择的任何其他字段下单
参考:
可以通过为要查询的集合创建范围筛选器字段和下一个要排序的字段的复合索引来实现这一点
因此,在本例中,您需要使用orderStatus DESC
和date DESC
为orders
集合创建一个复合索引
参考:
希望这有用。试试这个:
this.afs.collection('orders', ref=> ref.where('orderStatus', '<', 7).orderBy('date', 'desc'));
You have a where filter with an inequality (<, <=, >, or >=) on field 'orderStatus' and so you must also use 'orderStatus' as your first Query.orderBy(), but your first Query.orderBy() is on field 'date' instead.