【问题标题】:Firebase function how to search realtime databaseFirebase功能如何搜索实时数据库
【发布时间】:2021-07-29 14:48:44
【问题描述】:

我想使用 firebase 函数搜索 firebase 实时数据库 例如:我想在用户中搜索特定电子邮件是否已经存在。

【问题讨论】:

标签: firebase firebase-realtime-database google-cloud-functions


【解决方案1】:

您可以使用orderByChild()equalTo() 方法。

async function doesEmailExist(email) {
  const snap = await admin.database().ref("users").orderByChild("email").equalTo(email).once("value")
  return !!snap.val()
  // snap.val() is null if absent
  // function returns false is email is absent
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-25
    • 2022-01-19
    • 2018-11-21
    • 1970-01-01
    • 2020-11-30
    • 2019-08-07
    • 2021-10-07
    相关资源
    最近更新 更多