【问题标题】:AngularFirebase transaction and batch writes?Angular Firebase 事务和批量写入?
【发布时间】:2020-12-10 03:43:34
【问题描述】:
constructor(
     private afs: AngularFirestore,
    ) {}

dbAdd(){

this.afs.collection()

this.afs.firestore.collection()

}

这两者 (this.afs.collection() & this.afs.firestore.collection()) 有什么区别?以及何时使用它们?因为在事务和批处理过程中我们必须使用 this.db_cloud.firestore.collection() 而在读取数据时使用 this.db_cloud.collection()

【问题讨论】:

    标签: firebase google-cloud-firestore angularfire2


    【解决方案1】:

    基本上发生的情况是 AngularFire2 本身不支持 Transactions,因此它必须依赖底层框架来完成,这就是 this.afs.firestore 所做的 - 它调用 Firestore SDK 为其进行事务。

    那么什么时候应该使用this.afs.firestore?每当您必须做一些不是在 AngularFire 中本机实现但存在于官方 SDK 中的事情时。交易和批次就是一个例子。

    作为参考,您可以查看GitHub issue thread,其中讨论了 AngularFire 的该功能的实现。

    【讨论】:

    • @Shubhendu 如果我的回答有用,请点击它左侧的点赞按钮 (▲)。如果它回答了您的问题,请单击复选标记 (✓) 接受它。这样其他人就知道你已经(充分地)得到了帮助。另请参阅 What should I do when someone answers my question? 遵循这些简单的规则,您可以提高自己的声誉得分,同时让我们有动力回答您的问题。
    猜你喜欢
    • 2022-01-25
    • 1970-01-01
    • 2018-04-26
    • 2020-08-09
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-28
    相关资源
    最近更新 更多