Google cloud platform 如何在云函数中获取快照的ID?
我正在使用云函数在firestore中添加新文档时触发,但我无法在线找到如何获取此文档的ID 这是我的代码:Google cloud platform 如何在云函数中获取快照的ID?,google-cloud-platform,google-cloud-firestore,Google Cloud Platform,Google Cloud Firestore,我正在使用云函数在firestore中添加新文档时触发,但我无法在线找到如何获取此文档的ID 这是我的代码: exports.sendWelcomeEmail = functions.firestore .document(`users/{user}`) .onCreate(async (snap, context) => { const email = snap.data().userEmail; // The email of the user.
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);
});
我需要从“snap”中获取Id我如何才能做到这一点?您可以像访问任何JS属性一样访问特定字段,这是指向的链接。您可以像访问任何JS属性一样访问特定字段,这是指向的链接