update method
- T data
Updates the data with the specified ID.
Implementation
Future<K> update(T data) async {
final id = idGetterFunction(data);
final file = File('${directory.path}/$id.json');
if (!await file.exists()) {
throw Exception('Data with ID $id does not exist.');
}
final json = jsonEncode(toJsonFunction(data));
final encryptedJson = encriptionKey.isNotBlank ? json.applyXorEncrypt(encriptionKey) : json; // Encrypt the JSON if key is not blank
await file.writeAsString(encryptedJson);
return id;
}