copyCollection method

Future<HarnCollection> copyCollection(
  1. String sourceCollectionName,
  2. String targetCollectionName
)

Implementation

Future<HarnCollection> copyCollection(
    String sourceCollectionName, String targetCollectionName) async {
  final sourceCollection = collection(sourceCollectionName);
  final sourceDocuments = sourceCollection.find({});
  final targetCollection = HarnCollection(targetCollectionName, {});
  for (final document in sourceDocuments) {
    await targetCollection.insert(document);
  }
  return targetCollection;
}