all method

  1. @override
Future<void> all(
  1. Type type, {
  2. required bool iAmSure,
  3. String? subcollection,
})
override

Deletes all documents of a specific type from RDB.

Implementation

@override
Future<void> all(Type type, { required bool iAmSure, String? subcollection }) async {
  if (iAmSure) {
    final String? className = RDB.classNames[type];
    if (className == null) {
      throw UnsupportedError('No class name found for type: $type. Consider re-generating Firestorm data classes.');
    }

    if (subcollection == null) {
      await RDB.instance.ref(className).remove();
    }
    else {
      await RDB.instance.ref("$className:$subcollection").remove();
    }

    // //Get the objects of this type:
    // final reference = RDB.instance.ref(className);
    // final snapshot = await reference.once();
    // if (snapshot.snapshot.value == null) {
    //   return;
    // }
    //
    // Map<String, dynamic> data = RDBDeserializationHelper.snapshotToMap(snapshot.snapshot);
    // final Map<String, dynamic> updates = {};
    //
    // data.forEach((key, value) {
    //   String path = key.toString();
    //   updates[path] = null; // Mark for deletion
    // });
    //
    // // Perform the deletion in a single update operation:
    // return await reference.update(updates);
  }
}