diff method
Creates a new instance of the entity with updated values.
Computes the difference between the current entity state and an
oldVersion of the entity.
Implementation
@override
Map<String, dynamic>? diff(DatumEntity oldVersion) {
if (oldVersion is! ExcludableEntity) {
return toDatumMap(target: MapTarget.remote);
}
final remoteMap = toDatumMap(target: MapTarget.remote);
final oldRemoteMap = oldVersion.toDatumMap(target: MapTarget.remote);
final diff = <String, dynamic>{};
for (final key in remoteMap.keys) {
if (remoteMap[key] != oldRemoteMap[key]) diff[key] = remoteMap[key];
}
return diff.isEmpty ? null : diff;
}