Skip to content
Advertisement

How to retrieve arrays from FirebaseFirestore using Collections?

This is my Firestore database

JavaScript

Now here I want to retrieve Description and No. of Options which is saved in the form of an array, my code above prints other details of the data as well, with respect to the topic name selected hence I’ve used whereEqualTo(“Topic Name”, message)as my query(where the message is the topic I select). How to retrieve Description and No. of Options now in this. I can’t use DocumentReference because then I won’t be able to use whereEqualsTo. Please help!!!

Advertisement

Answer

To get the content of those two araays, please add the following two lines of code inside the for loop:

JavaScript

Right after this line:

JavaScript

If you need each element within those arrays, create a for loop for each list and get the corresponding data.

The result in the logcat will be:

JavaScript

For the first array, and:

JavaScript

For the second array.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement