you can not order a Query in Firestore

1

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.

    
asked by Jose Rosales 23.04.2018 в 08:44
source

0 answers