Reputation: 143
Is it possible to have its query something like this
postRef
.orderByChild("dateCreated")
.startAt(startDate)
.limitToFirst(5)
.endAt(endDate)
Upvotes: 0
Views: 1018
Reputation: 464
I have always used limitToLast in the end.
Query query=mDatabase.getReference().child("posts").orderByChild("date").limitToLast(1);
https://firebase.google.com/docs/reference/js/firebase.database.Query
Take a look at this link maybe you will find what you need.
Upvotes: 1
Reputation: 5251
Yes, it is possible.
But, for better code comprehension you should define the range of your search first, and then limit the results count.
postRef.orderByChild("dateCreated").startAt(startDate).endAt(endDate).limitToFirst(5)
Upvotes: 0