delete<T> method
Deletes objects in the RDB using a single operation.
Implementation
Future<void> delete<T>(List<T> objects, { String? subcollection }) async {
Serializer? serializer = RDB.serializers[T];
if (serializer == null) {
throw UnsupportedError('No serializer found for type: $T. Consider re-generating Firestorm data classes.');
}
Map<String, dynamic> objectsToDelete = {};
//For each object, serialize it, and then add it to the list of updates:
for (var object in objects) {
var map = serializer(object);
if (map["id"] == null || map["id"].isEmpty) {
throw NullIDException(map);
}
objectsToDelete[RDB.constructPathForClassAndID(object.runtimeType, map["id"], subcollection: subcollection)] = null;
}
await RDB.instance.ref().update(objectsToDelete);
}