Currently, my data is stored in such structure:
Firebase Database
|__Posts
|__3Csdsadq931j(Post hash)
|__1
|__created: 1623414664 (timestamp)
message: "Hello"
msgID: 1
|__2
|__created: 1623414667 (timestamp)
message: "Bye"
msgID: 2
Currently, I have the posted hash of the chatroom. I would like to retrieve the posts by the most recent post, so from msgID 2 to 1.
However, I keep getting this failure message. "FIREBASE QUERY ERROR: Unable to get latest value for query FQuerySpec"
Here is my query:
// For this example: let postRoomID = "3Csdsadq931j"
let postReference: DatabaseReference = Database.database().reference().child("Posts").child(postRoomID)
postReference.queryOrdered(byChild: "created").queryLimited(toLast: 30).getData {error , snapshot in ...}
What am I doing wrong?