问题
I'm using the Firebase UI FirestorePagingAdapter, i have a colletion of posts
and i want to filter the post that are not from the current user and order them by timestamp
I tried doing this but i get inequality error:
override fun getPostFromLocation(viewLifecycleOwner:LifecycleOwner, location:String) :FirestorePagingOptions<Post>{
val query = firestore.collection(POST_COLLECTION)
.orderBy("timestamp", Query.Direction.DESCENDING)
.whereNotEqualTo("uid",auth.currentUser?.uid)
return FirestorePagingOptions.Builder<Post>()
.setLifecycleOwner(viewLifecycleOwner)
.setQuery(query, pagingConfig, Post::class.java)
.build()
}
Is there a way i can filter the results?
回答1:
If you want to use Firebase UI to manage the RecyclerView, you will have to filter the results with another condition on the query.
If you can't make the query return exactly what you want, you will not be able to use Firebase UI. Instead, you will have to manually perform the query, write code to filter the results, and apply those to a RecyclerView with your own adapter.
来源:https://stackoverflow.com/questions/65111509/is-there-a-way-to-filter-data-with-firebase-ui-recyclerview