【问题标题】:Firebase / Angularfire2: how to retrieve data when rules are managed by push ID?Firebase / Angularfire2:当规则由推送ID管理时如何检索数据?
【发布时间】:2016-12-25 08:52:22
【问题描述】:

要在 Angularfire2 中以列表的形式检索数据,我们使用以下代码:

const queryList = af.database.list('/items'); 

但是当数据库安全由 pushID 管理时,无法检索数据,如下所述:

{
    "rules": {
        “items”: {
            “$itemID”: {
                “.read”:condition
            }
        }
    }
}

除了使用 pushID (af.database.list('/items/pushID') 查询 firebase 之外,还有其他方法可以检索数据吗?

【问题讨论】:

    标签: firebase firebase-realtime-database angularfire2


    【解决方案1】:

    如果列表中的所有项目都有安全规则,允许所有人读取您的数据,那么您可以将“.read”:true 移动更高一级,并且可以通过af.database.list('/items') 请求获取所有项目。

    {
      "rules": {
         “items”: {
             “.read”:true
         }
       }
    }
    

    【讨论】:

    • .Read = true 只是一个例子。当然,我不会把它放在真正的项目中。 À 使用 comolex 条件。
    猜你喜欢
    • 2018-07-07
    • 2020-06-20
    • 1970-01-01
    • 2018-10-21
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 2017-05-22
    相关资源
    最近更新 更多