Firebase功能 - 循​​环访问事件值

时间:2017-06-12 21:47:55

标签: javascript firebase firebase-realtime-database

监听更改的firebase事件。

exports.sendTestEmail = functions.database.ref('/email/{pushID}')
  .onWrite(event => {

    // Only edit data when it is first created.
    if (event.data.previous.exists()) {
      return;
    }
    // Exit when the data is deleted.
    if (!event.data.exists()) {
      return;
    }

    return sendTestEmail(event);
  });

function sendTestEmail(email, event) {

    const users = event.data.val();
    console.log(users);

  });
}

这是console.log(用户)的结果:

{ '-Km8VHEPHExBtpIN_7q0': 
   { admin: 'false',
     birthday: '76',
     description: 'desc',
     email: 'user@gmail.com',
     first_name: 'fname',
     last_name: 'lname',
     level: 5,
     occupation: 'dev',
     occupationLevel: 'dev5',
     phone: '+8766',
     verified: false },
  '-KmSjAaxdCUvrPEQ8InI': 
   { admin: 'false',
     birthday: '1990',
     description: 'desc',
     email: 'email2@gmail.com',
     first_name: 'fname',
     last_name: 'lanam3',
     level: 4,
     occupation: 'dev',
     occupationLevel: 'dev4',
     phone: '+23434',
     verified: false } }

我似乎无法循环并获取向拥有电子邮件地址的用户发送电子邮件所需的电子邮件。

1 个答案:

答案 0 :(得分:0)

也许考虑这样的事情。

 ValueError: Error when checking target: expected dense_3 to have 4 dimensions, but got array with shape (16000, 2)