cloud firestore - Query with Data type fields

Asked

Viewed 203 times

1

In the android application that I’m trying to mount, I have a filter screen by registration date and I need to perform the query in the firestore cloud using this field, in the database it is the type Timestamp. I am currently trying to perform the query as follows:

    db.collection("Presenca")
                .whereGreaterThan("datacadastro", datacadastro)
                .get()
                .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task) {
                        if (task.isSuccessful()) {

                            for (QueryDocumentSnapshot document : task.getResult()) {

                                alunosList.add(
                                        new Presenca(
                                                document.getString("nome").toUpperCase(),
                                                document.getString("sala"),
                                                document.getDate("datacadastro")));


                                recyclerView.setAdapter(adapter);
                            }
                        }
                        else {
                            Log.w(TAG, "Error getting documents.", task.getException());
                        }
                    }
                });


    }

inserir a descrição da imagem aqui

Any tips on how to query these fields in the firestore cloud?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.