save method

  1. @override
Future<Change<Record>?> save(
  1. String key,
  2. Record record, {
  3. bool force = false,
})
override

Adds or updates the model at a given key in the Source.

Implementation

@override
Future<Change<Record>?> save(
  String key,
  Record record, {
  bool force = false,
}) async {
  var existing = map[key];
  if (existing == record) {
    if (!force) {
      return null;
    }
  }
  map[key] = record;
  if (existing == null) {
    return Added(key, record);
  }
  return Updated(key, record);
}