I have this document structure in Firestore:
and this code that brings all those documents that have a field pcIdCuenta = TRUE; He shows them on my list. pcIdCuenta can take the value of any document id of the accounts collection ("digitaldev", "famrosales", "jrosales", etc.)
TabHomeFragmet.fsdbData.collection("cuentas")
.whereEqualTo(pcIdCuenta, true)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for(DocumentSnapshot doc : task.getResult()){
aListaContactos.add(
new ContactoModel(
doc.getId(),
doc.get("nom").toString().trim(),
doc.get("img").toString().trim(),
aListaContactos.size()
)
);
adaContactos.notifyDataSetChanged();
}
} else {
Toast.makeText(getContext(), "No se pudo obtener la lista de contactos", Toast.LENGTH_SHORT).show();
}
}
});
but when I put this line
.orderBy("nom", Query.Direction.ASCENDING)
after .here and before .get (), it no longer returns the query and does not bring anything.