Hi all, could someone please explain me why my if ...
# android
x
Hi all, could someone please explain me why my if condition returned true while there is an existing item? I am using this code for months and it was working fine till today, while there is an existing item, it created a new one because the it.documents.isEmpty() returned true (in a success call). Thank you in advance!
Copy code
firestore.whereEqualTo(ITEM_ID, id)
            .get()
            .addOnSuccessListener {
                if (it.documents.isEmpty()) {
                    val details = ...

                    firestore.add(details)
                        .addOnSuccessListener { _ ->
                            ...
                        }
                } else {
                    for (document in it.documents) {
                        firestore.document(document.id)
                            .update(field, ...)
                    }
                }
            }