I am currently making an app using Firebase.
It is one of those bulletin boards that can be seen anywhere on the web.
But there was one problem.
This is a matter of date sorting.
I want to look at the recent date first, but I always see only the data I created first.
postRef.orderByChild('createData').startAt(reverseDate).limitToFirst(1).on('child_added',(data)=>{
console.log(data.val().name + data.val().createData);
})
result - >hello1496941142093
My firebase tree
My code is the same as above.
How can I check my recent posts first?
How Do I order reverse of firebase database?
You can specify the sort order for your data using orderBy() , and you can limit the number of documents retrieved using limit() . Note: An orderBy() clause also filters for existence of the given field.
The Firebase Admin SDKs support Firebase access in Java, Python, Node. js, and Go. To get started with a Firebase Admin SDK, see Add the Firebase Admin SDK to Your Server.
The total data in each write operation should be less than 256 MB. Multi-path updates are subject to the same size limitation.
The Firebase Database will always return results in ascending order. There is no way to reverse them.
There are two common workaround for this:
These options have been covered quite a few times before. So instead of repeating, I'll give a list of previous answers:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With