2017-10-14 168 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"} ] } ]