【问题标题】:How to take the data of a specific column in firebase?如何获取firebase中特定列的数据?
【发布时间】:2019-01-16 22:52:39
【问题描述】:

我正在尝试获取name 列的数据。我有表格users,里面有nameemailphone_number

下面的代码是我用来取表userskey 或行的id。这几乎与我使用 ref('users/'+key).remove() 的删除代码相同

async print(key) {
  console.log(firebase.database().ref('users/'+key))
}

我期望name 的输出,例如'John'

【问题讨论】:

标签: firebase ionic-framework firebase-realtime-database


【解决方案1】:

你得到的是参考。

您需要执行 .once('value') 以获取该引用的快照,然后对该快照执行 .val() 以获取数据

async print(key) 
{
  const name = await firebase.database().ref('users/'+key).once('value')
  console.log(name.val()))
}

【讨论】:

  • 因为你,我得到了我需要的东西。谢谢
猜你喜欢
  • 2021-10-25
  • 1970-01-01
  • 2017-09-03
  • 2019-07-03
  • 1970-01-01
  • 2020-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多