I am trying to use getAll() method in a firestore cloud function. The problem is when I use an array in getAll(), it throws an error:
[ts] Argument of type 'DocumentReference[]' is not assignable to parameter of type 'DocumentReference'. Property 'id' is missing in type 'DocumentReference[]'. const questionRefs: FirebaseFirestore.DocumentReference[]
getAll()
method looks like, it accepts FirebaseFirestore.DocumentReference[] array, but it doesn't.
Any idea, where the problem is?
const questionRefs = new Array<FirebaseFirestore.DocumentReference>();
for (const questionID of questions) {
const ref = admin.firestore().collection('question-bank').doc(questionID)
questionRefs.push(ref);
}
// then use getAll
admin.firestore().getAll(questionRefs).then(snapshots=>{
snapshots.forEach(snapshot=>{
// snapshot.data
console.log('A');
})
}).catch(err=>console.log('B'));