假设
devices
是一个对象数组,我认为您不能在那里分配您的函数,因为函数只需要一个参数就可以获得单个设备。尝试:
const db = admin.firestore()
const devicesRef = db.collection('devices')
const result = await devicesRef.get();
// adds all results to devices list
List<any> devices = [];
for (QueryDocumentSnapshot device : result.getResult()) {
devices.add(device);
}
devices.forEach((device idx, array) => {
if (idx === array.length -1) {
// Do specific task
}
// some async function
async (someOtherFunction) => {
// do something with individual device
}
});