【问题标题】:Firebase database transaction with AngularFire2使用 AngularFire2 的 Firebase 数据库事务
【发布时间】:2018-10-17 08:14:40
【问题描述】:

我们应该如何使用 AngularFire2 5.0.0-rc.7 版本的事务?

我目前有以下:

this.db.database.ref('path/to/my/count').transaction(count => {
      console.log(count);
      return count + 1;
    });

但是,即使 Firebase 数据库中的值设置为 1,计数始终作为 null 传递给事务方法的回调参数。

这样做的正确方法是什么?

【问题讨论】:

    标签: angular firebase firebase-realtime-database angularfire2


    【解决方案1】:

    进一步谷歌搜索后,我发现以下工作:

    this.db.object('path/to/my/count').query.ref.transaction(count => count ? ++count : 1);
    

    Source

    【讨论】:

      猜你喜欢
      • 2016-12-04
      • 1970-01-01
      • 2018-06-22
      • 1970-01-01
      • 2021-11-23
      • 2018-11-28
      • 2016-12-10
      • 1970-01-01
      • 2017-05-27
      相关资源
      最近更新 更多