Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何在云函数中获取快照的ID?_Google Cloud Platform_Google Cloud Firestore - Fatal编程技术网

Google cloud platform 如何在云函数中获取快照的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.

我正在使用云函数在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);
  });

我需要从“snap”中获取Id我如何才能做到这一点?

您可以像访问任何JS属性一样访问特定字段,这是指向的链接。

您可以像访问任何JS属性一样访问特定字段,这是指向的链接