upsert method
- T data
Create or update the data with the specified ID.
Implementation
Future<K> upsert(T data) async {
final id = idGetterFunction(data);
final file = File('${directory.path}/$id.json');
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;
}