I
I
iKest2017-12-11 07:27:45
JavaScript
iKest, 2017-12-11 07:27:45

Firestore: the total number of documents in the selection and getting them in chunks?

How to get the total number of documents in a selection from Google Firestore and how to get these documents in chunks (for example, from 1 to 20, from 21 to 40, etc.)? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DragoN DragoN, 2018-04-07
@DrDragoN

To get the number of documents using whereEqualTo , you need to do this:

FirebaseFirestore.getInstance().collection( "name_collection" )
        .whereEqualTo("field", "value" )
        .addSnapshotListener(
            new EventListener<QuerySnapshot>()
            {
              @Override
              public void onEvent( @Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException e )
              {
                                                                // Обработка ошибок
                                                                if ( e != null )
                                                                {
                                                                          return;
                                                                }

                Log.e( "MESSAGE", "Количество документов " + value.size() );

                                                                // Ниже действия над документами
                                                                ...
              }
            }
        );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question