using kotlin
fun upadteProductInterestedList(activity: Activity, productId: String, uid: String) {
mFirestore.collection(Constants.PRODUCTS)
.document(productId)
.update(Constants.PRODUCT_INTERESTED, FieldValue.arrayUnion(uid))
.addOnSuccessListener {e ->
when(activity) {
is CheckProductDetailsActivity -> {
activity.productInterestedSuccess()
}
}
}
.addOnFailureListener { e ->
when(activity) {
is CheckProductDetailsActivity -> {
activity.hideProgressDialog()
}
}
Log.e(
activity.javaClass.simpleName,
"Error while updating profile",
e
)
}
}
I am using this function to update a array of ids inside firebase document and getting
"java.lang.IllegalArgumentException: Invalid document reference. Document references must have an even number of segments, but products has 1" error when the function is called. Error (E/AndroidRuntime: FATAL EXCEPTION: main) also mentions where this function was called.
The documents in product collection have a field called "interested" which is a array of strings. i am trying to store the user id when user clickes on the button.