繁体   English   中英

如何在 Angular 中从 Firebase 导入 WriteBatch>

[英]How to import WriteBatch from Firebase in Angular>

我正在使用这个包来处理我的 Angular 应用程序中的 Firebase:

"@angular/fire": "^6.1.4",
"firebase": "^8.2.7",

我创建了一个服务来处理批处理操作:

import { WriteBatch } from 'firebase/firestore'; // Does not work
import { WriteBatch } from 'firebase'; // Does not work

export class FireStoreBatch {
  private _batch: WriteBatch;

  public Create(): void{
    this._batch = this.afs.firestore.batch();
  }

}

在此处输入图像描述

我需要添加哪个导入才能使用 WriteBatch?

我遇到了同样的问题,因为我想将 WriteBatch 作为参数传递给 function。我没有找到合适的导入,但能够使用FirebaseFirestore.WriteBatch传递WriteBatch

export const myFunction = (batch: FirebaseFirestore.WriteBatch) => {
  // do something
}

仅从外观上看,这也适用于您的代码:

export class FireStoreBatch {
  private _batch: FirebaseFirestore.WriteBatch;

  public Create(): void{
    this._batch = this.afs.firestore.batch();
  }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM