我在使用 firebase 進行分頁時遇到問題我每次檢索的結果限制為 5 個:通過示例向您展示問題會更容易:"myDb":{ "products": { "uid1" : { "name" : "hello", "uid" : "uid1", "size" : "1" } "uid2" : { "name" : "hello", "uid" : "uid2", "size" : "2" } "uid3" : { "name" : "hello", "uid" : "uid3", "size" : "34" } "uid4" : { "name" : "hello", "uid" : "uid4", "size" : "4" } "uid5" : { "name" : "hello", "uid" : "uid5", "size" : "15" } "uid6" : { "name" : "hello", "uid" : "uid6", "size" : "50" } }}當然,這不是我的真實數據,但現在讓我向您展示我的查詢,我正在使用 Angularfire。 getDatasByQuery(path:string, query:string){ return this.db.list(path, (ref) => { return (ref.orderByChild('name').startAt(query).limitToFirst(5)) }) }所以我實際上做的是獲取name最后結果中屬性的值,并用它進行另一個查詢來分頁。唯一的問題是這name等于"hello"一直。當然我可以增加限制,但主要問題保持不變我希望用戶按name屬性搜索并對結果進行分頁,正如您此時可能已經理解的那樣,我得到的唯一結果是第 5 個等于的結果name,"hello"并且永遠不會達到第六個。所以first query ==> ['uid1', 'uid2', 'uid3', 'uid4', 'uid5'] => second query => exactly the same results非常感謝任何幫助,如果您需要更多解釋,請告訴我。
當 Child 相同時,在 firebase 中使用實時數據庫進行分頁
梵蒂岡之花
2023-07-20 15:09:56