deleteWithIDs method

Future<void> deleteWithIDs(
  1. Type type,
  2. List<String> ids, {
  3. String? subcollection,
})

Deletes objects in the RDB using a single operation.

Implementation

Future<void> deleteWithIDs(Type type, List<String> ids, { String? subcollection }) async {
  Map<String, dynamic> objectsToDelete = {};
  final String? className = RDB.classNames[type];

  if (className == null) {
    throw UnsupportedError('No class name found for type: $type. Consider re-generating Firestorm data classes.');
  }

  //For each object, serialize it, and then add it to the list of updates:
  for (final String id in ids) {
    objectsToDelete[RDB.constructPathForClassAndID(className, id, subcollection: subcollection)] = null;
  }

  await RDB.instance.ref().update(objectsToDelete);
}