【发布时间】:2018-06-04 04:40:00
【问题描述】:
我正在构建一个Android 应用程序,使用Firestore 作为我的后端。我正在写一个文档中的多个集合,在某些情况下可以write 到一个文档,update 文档,然后delete 文档都在同一个WriteBatch 中。每当用户创建,然后deletes 同一WriteBatch 内的文档我的应用程序崩溃。以下是我收到的代码和错误。
private void executeBatchedWrite() {
WriteBatch batch = db.batch();
DocumentReference doc = notebookRef.document("123");
batch.set(doc, new Note("New Note", "New Note", 1));
batch.update(doc, "timestamp", FieldValue.serverTimestamp());
batch.delete(doc);
batch.commit();
}
我的应用程序崩溃并收到以下错误:
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.g.zza.zzb(SourceFile:324)
at com.google.firebase.firestore.g.zzd.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
【问题讨论】:
-
是否可以一次批量多次写入同一个文档?
-
@DauleDK 在同一个批次中多次写入同一个文档是没有问题的,只要我以后不删除文档就可以了
标签: android firebase google-cloud-firestore