[英]Android Firebase - Is it possible to use limitToFirst()/limitToLast() in between startAt() and endAt()
Is it possible to have its query something like this 是否可能有这样的查询
postRef
.orderByChild("dateCreated")
.startAt(startDate)
.limitToFirst(5)
.endAt(endDate)
I have always used limitToLast in the end. 最后,我一直都使用limitToLast。
Query query=mDatabase.getReference().child("posts").orderByChild("date").limitToLast(1);
https://firebase.google.com/docs/reference/js/firebase.database.Query https://firebase.google.com/docs/reference/js/firebase.database.Query
Take a look at this link maybe you will find what you need. 看一下此链接,也许您会找到所需的内容。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.