I am trying to get all documents that contain the array called absentDate
and in the array it must have the current day. For example since today is 12-28-2020 and document in the image has the array called absentDate
and in the array there is a 12-28-2020 string. So my query should have included that document. However when I run the query, no documents show up. All values in the array are string values by the way, if that info makes a difference.
[UPDATE] I have two recyclerview
on this activity. One right under the other.
//Query for Pickup Request
var pickupQuery = db.collection("Users").whereNotEqualTo("pickupTime", "").orderBy("pickupTime")
// RecyclerOptions for Pickup Request
var pickupOptions = pickupFirestoreOptions(pickupQuery)
pickupAdapter = PickupAdapter(pickupOptions)
binding.rvPickupList.adapter = pickupAdapter
binding.rvPickupList.layoutManager = LinearLayoutManager(this)
// ***** DOESNT WORK ******
// Query for Absent Request
val today = LocalDateTime.now()
val formattedToday = "${today.monthValue}-${today.dayOfMonth}-${today.year}"
Log.d("TAG", "$formattedToday")
var absentQuery = db.collection("Users").whereArrayContains("absentDate", formattedToday)
// RecyclerOptions for Absent Request
var absentOptions = absentFirestoreOptions(absentQuery)
absentAdapter = AbsentAdapter(absentOptions)
binding.rvAbsentList.adapter = absentAdapter
binding.rvAbsentList.layoutManager = LinearLayoutManager(this)
private fun pickupFirestoreOptions(query: Query): FirestoreRecyclerOptions<PickupData> {
return FirestoreRecyclerOptions.Builder<PickupData>().setQuery(query, SnapshotParser<PickupData> {
Log.d("TAG", "pickupFirestoreOptions ran")
val studentName = "${it.getString("studentFirstName")} ${it.getString("studentLastName")}"
var atCenter = it.getBoolean("atCenter")!!
val userId = it.id
val pickupTime = it.getString("pickupTime")!!
PickupData(studentName, atCenter, userId, pickupTime)
}).build()
}
private fun absentFirestoreOptions(query: Query): FirestoreRecyclerOptions<AbsentData> {
return FirestoreRecyclerOptions.Builder<AbsentData>().setQuery(query, SnapshotParser<AbsentData> {
Log.d("TAG", "absentFirestoreOptions ran")
val studentName = "${it.getString("studentFirstName")} ${it.getString("studentLastName")}"
AbsentData(studentName)
}).build()
}