save method

  1. @override
Future save(
  1. String? correlation_id,
  2. List<T?> items
)
override

Saves given data items to external JSON file.

  • correlation_id (optional) transaction id to trace execution through call chain.
  • items list if data items to save Return Future that error or null for success.

Implementation

@override
Future save(String? correlation_id, List<T?> items) async {
  try {
    var json = JsonConverter.toJson(items);
    File(path!).writeAsStringSync(json!);
    return null;
  } catch (ex) {
    var err = FileException(correlation_id, 'WRITE_FAILED',
            'Failed to write data file: ' + path.toString())
        .withCause(ex);
    throw err;
  }
}