toDatumMap method

  1. @override
Map<String, dynamic> toDatumMap({
  1. MapTarget target = MapTarget.local,
})
override

Converts the entity to a Map<String, dynamic> for persistence.

Implementation

@override
Map<String, dynamic> toDatumMap({MapTarget target = MapTarget.local}) {
  final map = <String, dynamic>{
    'id': id,
    'userId': userId,
    'name': name,
    'modifiedAt': modifiedAt.toIso8601String(),
    'createdAt': createdAt.toIso8601String(),
    'version': version,
    'isDeleted': isDeleted,
  };

  if (target == MapTarget.local) {
    if (localOnlyFields != null) map.addAll(localOnlyFields!);
  } else {
    if (remoteOnlyFields != null) map.addAll(remoteOnlyFields!);
  }
  return map;
}