many<T> method
Deletes multiple documents from Firestore using a list of objects.
Implementation
@override
Future<void> many<T>(List<T> objects, { String? subcollection }) {
if (objects.isEmpty) return Future.value();
if (objects.length > 500) {
throw ArgumentError('Batch delete limit exceeded. Maximum 500 objects allowed.');
}
final String? className = LS.classNames[objects[0].runtimeType];
if (className == null) {
throw UnsupportedError('No class name found for type: ${objects[0].runtimeType}. Consider re-generating Firestorm data classes.');
}
List<Future<void>> futures = [];
for (dynamic object in objects) {
if (object.id == null) {
continue; //skip
}
DocumentRef ref = LS.instance.collection(className).doc(object.id);
if (subcollection != null) {
ref = LS.instance.collection(className).doc(subcollection).collection(subcollection).doc(object.id);
}
futures.add(ref.delete());
}
return Future.wait(futures);
}