deleteCollection method
Implementation
@override
FutureOr<void> deleteCollection({
String absolutePath = '',
String collectionPath = '',
}) async {
assert(
absolutePath.isNotEmpty != collectionPath.isNotEmpty,
'Only one parameter of absolutePath or documentPath must be used',
);
var colPath = absolutePath;
if (colPath.isEmpty) {
colPath = firestorePathUtils.absolutePathFromRelative(collectionPath);
}
final collectionParent = di<PathUtils>().parent(colPath);
final collectionName = di<PathUtils>().name(colPath);
final documents = await _getCollectionDocuments(
documentPath: collectionParent,
collectionName: collectionName,
);
for (final document in documents) {
if (document.name != null) {
await deleteDocument(absolutePath: document.name!);
}
}
}