I am trying query a number of documents in different collections with array-contains-any, by using Promise.all() to get all the documents at once.
I've checked whether the path is correct, whether the documents exist, whether the key exists in the document and everything is ok.
The querySnapshots and snapshots have no data retrieved. At some point of the log says: "_size":0,"_materializedDocs":null.
let promises = []
depIds.forEach(id => {
const prodIds = groupedProducts[id].reduce((acc, val) => [...acc, val.prodId], []);
console.log("All prodIds: ", prodIds, "; also id is: ", id);
promise = admin.firestore()
.collection('Products')
.doc('Departments')
.collection(id)
.where('key', 'array-contains-any', prodIds)
.get();
promises.push(promise)
})
const querySnapshots = await Promise.all(promises);
const snapshots = querySnapshots.map(doc => {
console.log("docs: ", JSON.stringify(doc))
return doc;
});
So my questions are:
Is it possible to query as above?
How to get the actual data after the
Promise.all()command?
I appreciate any help!