当将新文档添加到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,该怎么办?