all method
Deletes all documents of a specific type from RDB.
Implementation
Future<void> all(Type type, { required bool iAmSure, String? subcollection }) async {
if (iAmSure) {
//Get the objects of this type:
final reference = RDB.instance.ref(type.toString());
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);
}
}