I'm new using Firebase and I can't find how to do what sounds really simple to do : list all the latest entries of my database.
Here is a screenshot of what my database looks like :
So, I'm trying to list the latest entries like that :
// picturesRef = FIRDatabase.database().reference().child("pictures")
let _ = self.picturesRef.queryOrdered(byChild: "createdTime").queryLimited(toLast: 50).observe(.value, with: { snapshot in
// Stocking the result into picturesArr array
for elem in picturesArr {
print(elem.createdTime)
}
})
And right now, when I'm displaying the createdTime value of each item, I have something like :
- 1484738582.0
- 1484000086.0
- 1484738279.0
- 1484734358.0
- 1484625525.0
- 1484728677.0
Which doesn't seem to be ordered from the oldest entry to the newest one...
Also, when I replace "createdTime" in the query by "fieldThatDoesntExist", I have the exact same result.
Anyone would know where did I do something wrong in the code ? Thanks in advance !