首页 > 解决方案 > 如何获得子收藏电子邮件

问题描述

所以我目前正在尝试访问我访问的电子邮件。它只打印完整的字符串,但我完全不确定如何获取电子邮件

function addLead() {
   db.collection('entities')
   .doc('0') // change to the current user id 
   .get().then((user)=>{
       if(user.exists){
           // now you can do something with user
           console.log(user.data())
       }
   });
  };  
addLead();

它打印出这个:

{ email: '123googlemail.com', user: 'X', pass: 'XD' }

每次我收到这封电子邮件并使用它时,我都希望它选择下一个 ID,即“1”

所以它会转到“entities/0/email”,然后一旦使用就转到“entities/1/email”等

希望有人能帮忙

标签: javascriptfirebaseautomationgoogle-cloud-firestore

解决方案


所以我想通了,你必须使用正常的过程,但将(doc)传递给一个函数:

  db.collection('entities').doc("0").get().then(function(doc) {
    const passName = doc.data().pass;
    console.log(doc.data().pass);

希望这会帮助任何被卡住的人,它进入实体,打开它,找到具有 ID 的人,0然后获取详细信息。


推荐阅读