I Am trying to create a node wrapper around my firebase function on a different server
technically using firebase as my main Database
And anytime I try to read using the default query function in the doc
const db = firebase-admin.firestore()
const data = await db.collection("cities").get()
Now instead of getting an array of objects like this
"_query": {
"_firestore": {
"projectId": "fir-demo-jd1"
},
"_queryOptions": {
"parentPath": {
"segments": []
},
"collectionId": "bets",
"converter": {},
"allDescendants": false,
"fieldFilters": [
],
"fieldOrders": [
],
"limit": null,
"limitType": 0,
"kindless": false,
"requireConsistency": true
},
"_serializer": {
"allowUndefined": false
},
"_allowUndefined": false
},
"_readTime": {
"_seconds": 1676797103,
"_nanoseconds": 433061000
},
"_size": 2,
"_materializedDocs": null,
"_materializedChanges": null
},
What I want is to be able to see the list of country alone
As I woud later to use paganation also on the data
thats like
.limit()
with ease
2
Answers
So Apartly I have to map and convert it to JSON using this function
I thought firebase handled all this under the hood
db.collection("cities").get()
returns aQuerySnapshot
and from there you can loop over theDocumentSnapshot
s, as explained in the doc: