如何在Firebase的iOS SDK上执行分页查询? [英] How do I perform a pagination query on Firebase's iOS SDK?
问题描述
这是我的模特。
messagesRef = Firebase(url:https://+ CONSTANTS.FirebaseDB +.firebaseio.com / messages / 1: ($)
messagesRef.queryLimitedToLast(5).observeEventType(FEventType.ChildAdded,withBlock:{(snapshot)in
self.message_list.append(snapshot)// it works。
}) ;
});
我的代码工作 - 得到最后5条消息(8-12)。
但是,如果我有一个函数查询接下来的5条消息(2-6)呢?有一个开始和抵消。我如何查询这个?
消息库.firebaseio.com / messages / 1:1000)messagesRef
.queryOrderedByKey()
.queryStartingAtValue(5)
.queryEndingAtValue(10)
.observeEventType(FEventType.ChildAdded ,withBlock:{(snapshot)in self.message_list.append(snapshot)});
这是黑暗中的一种镜头,但它似乎应该基于文档< a href =https://www.firebase.com/docs/ios-api/Classes/Firebase.html#//api/name/queryStartingAtValue> https://www.firebase.com/docs/ios-api /Classes/Firebase.html#//api/name/queryStartingAtValue :
This is my model.
messagesRef = Firebase(url: "https://"+CONSTANTS.FirebaseDB+".firebaseio.com/messages/1:1000")
messagesRef.queryLimitedToLast(5).observeEventType(FEventType.ChildAdded, withBlock: { (snapshot) in
self.message_list.append(snapshot) // it works.
});
});
My code works -- it gets the last 5 messages (8-12).
However, what if I have a function query the next 5 messages (2-6)? With a start and offset. How can I query this?
messagesRef = Firebase(url: "https://"+CONSTANTS.FirebaseDB+".firebaseio.com/messages/1:1000")messagesRef
.queryOrderedByKey()
.queryStartingAtValue(5)
.queryEndingAtValue(10)
.observeEventType(FEventType.ChildAdded, withBlock: { (snapshot) in self.message_list.append(snapshot) });
This is kind of a shot in the dark but it seems like it should work based on documentation here https://www.firebase.com/docs/ios-api/Classes/Firebase.html#//api/name/queryStartingAtValue:
这篇关于如何在Firebase的iOS SDK上执行分页查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!