How can I return a collection of documents from firestore database. For example, I have a collection named countries in cloud firestore, and I want to fetch all the country names and ids as json , like this
[
{
"countryId" : 1,
"countryName" : "Any"
},
{
"countryId" : 2,
"countryName" : "India"
}
]
Now I am doing a foreach on the snapshot. Is that the only way to convert a collection to json?