recursiveDelete method

JSPromise<JSAny?> recursiveDelete(
  1. JSObject ref, [
  2. BulkWriter bulkWriter
])

Retrieves multiple documents from Firestore.

The first argument is required and must be of type DocumentReference followed by any additional DocumentReference documents. If used, the optional ReadOptions must be the last argument.

@param {Array.<DocumentReference|ReadOptions>} documentRefsOrReadOptions The DocumentReferences to receive, followed by an optional field mask. @return A Promise that resolves with an array of resulting document snapshots. 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.

recursiveDelete() uses a BulkWriter instance with default settings to perform the deletes. To customize throttling rates or add success/error callbacks, pass in a custom BulkWriter instance.

@param ref The reference of a document or collection to delete. @param bulkWriter A custom BulkWriter instance used to perform the deletes. @return A promise that resolves when all deletes have been performed. The promise is rejected if any of the deletes fail.

@example // Recursively delete a reference and log the references of failures. const bulkWriter = firestore.bulkWriter(); bulkWriter .onWriteError((error) => { if ( error.failedAttempts < MAX_RETRY_ATTEMPTS ) { return true; } else { console.log('Failed write at document: ', error.documentRef.path); return false; } }); await firestore.recursiveDelete(docRef, bulkWriter);

Implementation

// TODO: Is this possible in dart?
// getAll(
//   ...documentRefsOrReadOptions: Array<DocumentReference | ReadOptions>
// ): Promise<Array<DocumentSnapshot>>;

/// 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.
///
/// `recursiveDelete()` uses a BulkWriter instance with default settings to
/// perform the deletes. To customize throttling rates or add success/error
/// callbacks, pass in a custom BulkWriter instance.
///
/// @param ref The reference of a document or collection to delete.
/// @param bulkWriter A custom BulkWriter instance used to perform the
/// deletes.
/// @return A promise that resolves when all deletes have been performed.
/// The promise is rejected if any of the deletes fail.
///
/// @example
/// // Recursively delete a reference and log the references of failures.
/// const bulkWriter = firestore.bulkWriter();
/// bulkWriter
///   .onWriteError((error) => {
///     if (
///       error.failedAttempts < MAX_RETRY_ATTEMPTS
///     ) {
///       return true;
///     } else {
///       console.log('Failed write at document: ', error.documentRef.path);
///       return false;
///     }
///   });
/// await firestore.recursiveDelete(docRef, bulkWriter);
external JSPromise recursiveDelete(JSObject ref, [BulkWriter bulkWriter]);