2017-10-14 166 views
2

实现排序列表已经尝试过:我如何通过最新的与公司的FireStore查询

this.afs.collection('profiles', ref => { 
 
    return ref.where('createdAt', '>', 0).orderBy('createdAt', 'desc'); 
 
    });

,但它不能正常工作。

+0

见我的答案在这里,这可能有助于https://stackoverflow.com/questions/46745076/how-to-orderbyvalue-onsnapshot-using-firestore –

回答

0

你什么错误?

云公司的FireStore使用索引,每次查询。你可以阅读更多关于here

对于您的简单查询,它的云看起来像这样(如果使用的是firebase cli),否则您也可以使用控制台中的链接(从错误中)创建索引。

"indexes": [ { "collectionId": "profiles", "fields": [ { "fieldPath": "createdAt", "mode": "DESCENDING"} ] } ]