upsert static method

Future<Exception?> upsert(
  1. String table,
  2. String key,
  3. Map<String, dynamic> map
)

Implementation

static Future<Exception?> upsert(
    String table,
    String key,
    Map<String, dynamic> map) async {

  if (!initialized) return null;

  Exception? exception;
  try {
    var box = await Hive.openBox(table);
    await box.put(key, map);
  } on Exception catch (e) {
    Log().error(
        'Error Inserting/Updating Record Key [$key] in Table [$table]');
    Log().exception(e,
        caller: 'Future<Exception?> update($table, $key, $map) async');
    exception = e;
  }
  return exception;
}