I have a Firestore collection where one of the values is an array of document IDs. My goal is to retrieve all items in the collection as well as all documents stored within the array of IDs. Here is the structure of my collection: https://i.sstatic.net/rA8pj.png
This is my code:
export const getFeaturedMixes = functions.https.onRequest((request, response) => {
let result:any[] = []
featuredMixes.get().then(mixesSnap => {
mixesSnap.forEach(doc => {
let docId = doc.id
let ids = doc.data().tracks
let resultTracks:any[] = []
ids.forEach(id => {
let t = tracksCollection.doc(id.track_id).get()
resultTracks.push({'id' : id.track_id, 'data': t})
})
result.push({'id':docId, 'tracks': resultTracks})
})
return result
})
.then(results => {
response.status(200).send(results)
}).catch(function(error) {
response.status(400).send(error)
})
});
However, the response I receive is missing the actual document data:
{
"id": "Xm4TJAnKcXJAuaZr",
"tracks": [
{
"id": "FG3xXfldeJBbl8PY6",
"data": {
"domain": {
"domain": null,
"_events": {},
"_eventsCount": 1,
"members": []
}
}
},
{
"id": "ONRfLIh89amSdcLt",
"data": {
"domain": {
"domain": null,
"_events": {},
"_eventsCount": 1,
"members": []
}
}
}
]
}
The response does not contain the actual document data.