当新文档添加到 firestore 时,我正在使用云函数进行跳动,但我无法在线找到如何获取此文档的 ID。
这是我的代码:
exports.sendWelcomeEmail = functions.firestore
.document(`users/{user}`)
.onCreate(async (snap, context) => {
const email = snap.data().userEmail; // The email of the user.
const displayName = snap.data().userName; // The display name of the user.
return sendWelcomeEmail(email, displayName);
});
我需要从"快照"中获取 ID,我该怎么做?
您可以像访问任何 JS 属性一样访问特定字段,这是文档的链接。