Skip to content

Conversation

@thebrianchen
Copy link

@thebrianchen thebrianchen commented May 25, 2021

This PR adds recursive delete functionality to the top level Firestore class in a method that recursively deletes all documents and subcollections at and under the specified level. If any delete fails, the promise is rejected with an error message containing the number of failed deletes and the stack trace of the last failed delete. The provided reference is deleted regardless of whether all deletes succeeded.

Note that this is still a BetaApi and may change in the future.

Example:

// Recursively delete a document reference and log the references of failures. BulkWriter bulkWriter = firestore.bulkWriter(); bulkWriter.addWriteErrorListener( (BulkWriterException error) -> { if (error.getFailedAttempts() < MAX_RETRY_ATTEMPTS) { return true; } else { System.out.println("Failed write at document: " + error.getDocumentReference()); return false; } } ); firestore.recursiveDelete(documentReference, bulkWriter);
@thebrianchen thebrianchen requested a review from a team as a code owner May 25, 2021 15:16
@thebrianchen thebrianchen requested a review from a team May 25, 2021 15:16
@thebrianchen thebrianchen requested a review from a team as a code owner May 25, 2021 15:16
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/java-firestore API. label May 25, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/java-firestore API. cla: yes This human has signed the Contributor License Agreement.

2 participants