This question already has answers here:
How to sort Firebase records by two fields (Android) [duplicate]
(1 answer)
Query based on multiple where clauses in Firebase
(8 answers)
Closed 8 months ago.
I am trying to get data of "fromuser" equals to "moeez" and "status" equals to "pending" in firebase
using query
Query query1 = databaseReference.child("fromuser").equalTo(name).orderByChild("status").equalTo(status_value);
gives error java.lang.IllegalArgumentException: You can't combine multiple orderBy calls!
Now how can i retrieve both values at same time to display sorted data??
Related
This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Firebase multiple WHERE clause in query [duplicate]
(2 answers)
Closed 4 months ago.
First of all, I am coding in Kotlin.
I'd like to arrange the posts stored in the Realtime Database for a certain period of time based on the number of likes and display them in the RecyclerView.
my database structure
"posts": {
"key": {
"uid": "NHYVkW...",
"title" : "Title",
"time": "1666852764028",
"like" : 2
}
I've read about methods orderByChild(), startAt(), and endAt(), but I don't know how to use them in combination.
The examples I've seen set startAt() and endAt() for the key that enters orderByChild().
But I want the sort to be based on like and the start and end points based on time.
Any examples I can refer to?
Please help.
This question already has answers here:
Query Firebase Database with two between conditions
(1 answer)
How to query Firebase for value between two keys
(2 answers)
Closed 3 years ago.
I'm trying to get all "par***" data sets where two dates are between "from" and "to" (x is greater than "from" and y is less than "to").
My Firebase structure is:
I'm using android with java and firebase realtime database.
This question already has answers here:
Firebase Android - startAt() and endAt() not working correctly?
(2 answers)
Closed 3 years ago.
I have objects named "trips" saved in the firebase database, which can uniquely identify using seasonCode and TripCode combination.
Now I want to retrieve all the trips which include a particular seasonCode (ex: trips with seasonCode="SeasonCose1"). but need to extract data set chunk wise. (let's say 10 trips at a time)
FirebaseDatabase.getInstance(firebaseApp).getReference("resources").child("trips").orderByChild("seasonCode").equalTo("seasonCode1").limitToFirst(10)
I figured this query returns first 10 trips wich seasonCode="SeasonCode1". if I have last retrieved "Trip" object, how can I retrieve the next 10 trips with seasonCode="seasonCode1"?
Finally found a solution. I can get that through wildcard queries.
Firebase Android - startAt() and endAt() not working correctly?
This question already has an answer here:
Unexpected Behavior When Query by .whereArrayContains()
(1 answer)
Closed 4 years ago.
To get the data from the firestore collection for instance update I tried the below query.
docRef.whereArrayContains().orderBy().limit()
com.google.firebase.firestore.FirebaseFirestoreException: FAILED_PRECONDITION: The query requires an index. You can create it here:
If you attempt a compound query with a range clause that doesn't map to an existing index, you receive an error. The error message includes a direct link to create the missing index in the Firebase console.
Manage indexes in Cloud Firestore
When you get the error check LogCat for the link
This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 6 years ago.
For example if I take a simple SQL query:
Select user WHERE name = jack ORDER BY date_added ASC
The firebase Query to retreive all users with name jack will look like:
myRef.orderByChild("name").equalTo("jack")
but if I add
myRef.orderByChild("name").equalTo("jack").orderByChild("date_added")
I will get
java.lang.IllegalArgumentException: You can't combine multiple orderBy calls!
so how can I order by ASC and DESC after using orderBy and equalto?
you can't use orderByChild more than one time.
i ran into this problem and i ended up by using orderByChild once and filter the data on my client .
you can refer to this answer , it will help you