restoreFromMap static method

Future<List<String>> restoreFromMap(
  1. dynamic theItems,
  2. RepositoryBase repository,
  3. String appId, {
  4. PostProcessing? postProcessing,
  5. Map<String, String>? newDocumentIds,
})

Implementation

static Future<List<String>> restoreFromMap(
  dynamic theItems,
  RepositoryBase repository,
  String appId, {
  PostProcessing? postProcessing,
  Map<String, String>? newDocumentIds,
}) async {
  List<String> documentIds = [];
  if (theItems != null) {
    for (var theNewItem in theItems) {
      var documentID = renameDoc(theNewItem, newDocumentIds);
      if (postProcessing != null) {
        postProcessing(theNewItem);
      }

      EntityBase entity =
          repository.fromMap(theNewItem, newDocumentIds: newDocumentIds);
      var newEntity = entity.switchAppId(newAppId: appId);
      await repository.addEntity(documentID, newEntity);
      documentIds.add(documentID);
    }
  }
  return documentIds;
}