Я написал нижеприведенный код, чтобы определить, когда комментарий был добавлен в БД, а затем ответить обновлением узла временной шкалы, проблема в том, что он фактически не обновляется. Почему это не работает?
export const onCommentAdded = functions.database
.ref('/Comments/{receiverUID}/{postID}/{mediaNum}/{commentID}')
.onCreate((snapshot, context) => {
const uid = context.params.uid
const newCommentUID = snapshot.child("UID").val()
console.log(newCommentUID, " the comment")
return addNewCommentNotif(uid, newCommentUID)
})
function addNewCommentNotif(uuid: string, newCommentUID: string) {
//NotifTimeline/uid/NewNotif (someuniqueVal)/commentID
const randID = Math.floor(100000000 + Math.random() * 900000000);
const notifTimelineRef = admin.database().ref("NotifTimeline").child(uuid).child(newCommentUID + ":" + randID).child("NewComment")
notifTimelineRef.set(newCommentUID)//update
.then(() => {
console.log("Success updating this uid comment timeline")
})
.catch((error: string) => {
console.log("Error in catch: "+error)
response.status(500).send(error)
})
return Promise.resolve();
}