嗨,我是云功能的新手,我在尝试对家庭文档进行Chang(更新)时更新集合中的名称,但我无法更新名称在集合中,“ strong>”似乎在第一个控制台日志之后没有执行。
exports.onClassroomUpdate = functions.firestore.document("family/{id}").onUpdate((change, context) => {
const documentId = context.params.id;
const after = change.after.data();
let users = admin.firestore().collection('users').where('family.id', '==', documentId);
return users.get().then((querySnapshot) => {
let chain = Promise.resolve();
console.log('work');
querySnapshot.forEach((doc) => {
console.log('not working');
chain = chain.then(() => {
return admin.firestore().collection('users').doc(doc.id).update({
name: after.name
});
});
});
return Promise.all([chain]);
})
}).catch(err => {
console.log(err);
return Promise.reject(err);
});
)}