I'm trying to perform a compound and
Firestore query in Kotlin by following this guide:
My code is as follows:
val query =
Firebase.firestore
.collection("profiles")
.where(
Filter.and(
Filter.inArray("profileGender", preferenceGenderArray),
Filter.equalTo("profilePaused", false)
)
)
.get()
Android Studio is giving me these errors in the IDE before I can run this:
In my build.gradle(app) I have implementation 'com.google.firebase:firebase-firestore-ktx
What am I doing wrong here?
As long as you're using the correct dependencies and the following imports:
import com.google.firebase.Firebase
import com.google.firebase.firestore.Filter
import com.google.firebase.firestore.firestore
Your query should work.
I'm trying to perform a compound
and
Firestore query in Kotlin.
If you only want to create an and
query, according to the official documentation regarding compound (AND) queries, there is no need to use a Filter with an and
condition, you can simply use:
val query =
Firebase.firestore
.collection("profiles")
.whereIn("profileGender", preferenceGenderArray)
.equalTo("profilePaused", false)
.get()
For which you should create an index.