我试图在firestore云函数中使用getAll()方法.问题是当我在getAll()中使用数组时,它会抛出一个错误:
[ts]类型'DocumentReference []'的参数不能分配给'DocumentReference'类型的参数.'DocumentReference []'类型中缺少属性'id'.const questionRefs:FirebaseFirestore.DocumentReference []
getAll()方法看来,它接受FirebaseFirestore.DocumentReference []数组,但它不接受.任何想法,问题出在哪里?
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'));
Run Code Online (Sandbox Code Playgroud)