Reputation: 105
I am using childByAutoId
to save each message in Firebase.
now when observing data, I want each query to get 10 older messages using .queryStarting(atValue: )
.queryEnding(atValue: )
Is it possible with childByAutoId
? Thanks
Upvotes: 1
Views: 79
Reputation: 35657
Sure. But that's not generally best practice - don't query by the key. Query by a child in the node.
messages
-Y8hji98jasdjkas
datestamp: "20170405"
-Yin99s9ks9kksok
datestamp: "20170407"
-Y7iijs9jsk9999j
datestamp: "20170409"
queryOrdered(byChild: "datestamp").queryStarting(atValue: "20170405")
.queryEnding(atValue: "20170408")
will retrive these two older child nodes
-Y8hji98jasdjkas
datestamp: "20170405"
-Yin99s9ks9kksok
datestamp: "20170407"
Upvotes: 2