Я делаю приложение на Android и Firestore. Когда я пытаюсь загрузить информацию в Firestore, используя pactor < /strong>, я получаю следующее сообщение: < /p>
com.google.firebase.firestore.firebasefirestoreexexcept />
Я понимаю, что это стандартное ограничение для всех (см. Использование и ограничения), но как можно разделить партию на несколько партий, чтобы избежать этой проблемы? < /p>
WriteBatch batch = mFirestore.batch();
batch.set(personRef, personData); // This is done 1 time
batch.set(productRef, myProduct, SetOptions.merge()); // This is done multiple times
batch.set(inventoryRef, inventoryData); // This is done multiple times
batch.set(clientRef, clientData); // This is done multiple times
batch.commit().addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
Log.d(TAG, "Batch successfully completed!");
} else {
Log.d(TAG, "Error batch: ", task.getException());
}
}
});
< /code>
Я искал информацию об этом, но я нахожу только решения для веб -сайта, используя Async /task < /code>, ничего, что не помогает для Android.WriteBatch batch = mFirestore.batch();
int operationCounter = 0;
// This is just 1 time
DocumentReference personRef = mFirestore.collection..................
batch.set(personRef, personData);
// Multiple times
for (Product product : myProductList) {
DocumentReference productRef = mFirestore.collection...............
batch.set(productRef, product, SetOptions.merge());
operationCounter++;
if (operationCounter == 500) {
batch.commit();
// Start a new one
batch = mFirestore.batch();
// Reset counter
operationCounter = 0;
}
// This is just 1 time
DocumentReference inventoryRef = mFirestore.collection..................
batch.set(inventoryRef, inventory);
< /code>
Моя цель - иметь возможность генерировать несколько партий, чтобы избежать упомянутой ошибки и иметь возможность выполнять их один за другим. < /p>
Подробнее здесь: https://stackoverflow.com/questions/574 ... ore-from-a