1
다음과 같은 클라우드 기능이있어 효과적입니다. 실시간 데이터베이스에서 업데이트를 수신하고 이에 따라 Firestore를 업데이트합니다.Google Cloud 기능에서 처리되지 않은 거부
내 사용자가 아직 내 Firestore 데이터베이스가없는 경우를 제외하고는 모든 것이 좋습니다.
Google Cloud 기능 로그에 표시되는 Unhandled rejection
을 처리해야하는 곳입니다.
기능의 단축 버전에서 내 db.collection("users").where("email", "==", email).get()
에 대해 앞으로 이동하고 충돌을 방지하는 기능을 중지하는 방법을 참조하십시오.
exports.updateActivities = functions.database.ref("delegates/{userId}/activities").onWrite((event) => {
//Here I set all the needed variable
return rtdb.ref(`delegates/${userId}/email`).once("value", snapshot => {
//Here I'm fine, email is always present.
})
.then(() => {
db.collection("users").where("email", "==", email).get()
//This is where I need to handle when there is not matching value, to stop moving forward.
.then(querySnapshot => {
querySnapshot.forEach(val => {
console.log("Found match in FireStore " + val.id);
firestoreId = val.id;
})
})
.then(() => {
//Here I start my update on Firestore
});
})
});
감사합니다, 그래서'.catch (오류 => {console.error (오류)와; 반환 })'나는 또한 함수를 멈추거나'return'을 선택하지 않습니다. – Benoit
비동기 작업을 수행하는 함수에서 항상 약속을 반환해야합니다. –