export const newNodeDetected = functions.database.ref('counter/likes/{postId}').onWrite((snapshot, context) => {
const likeCount = snapshot.after.numChildren();
const key = snapshot.after.key;
snapshot.after.forEach(child => {
console.log("[--] loop", child.child('{sd}'));
});
console.log("[--] true or false", snapshot.after.val());
console.log("[--] value", likeCount);
console.log("[--] key", snapshot.after.key);
console.log(`[--] keystring questions ${key}`);
database.ref(`posts/${key}/likeCount`).set(likeCount).catch(console.error);
});如果我们不包括快照,我们只有上下文,它还会从那个位置下载数据吗?
发布于 2020-08-12 17:11:24
您的功能实际上并不是“下载”任何东西。它所做的就是写到数据库中。
传入的快照根本不是真正的“下载”。在所有情况下,该快照都将传递给您的函数。您不能告诉云函数不提供它。当您的函数运行时,它将完全存储在内存中,因此访问它的速度将非常快。
https://stackoverflow.com/questions/63381488
复制相似问题