toMap method

  1. @override
Map<String, Object?> toMap()

Converts this DTO to a map suitable for database insertion.

Returns a map with column names as keys. Only non-null/provided fields should be included.

Implementation

@override
Map<String, Object?> toMap() {
  return <String, Object?>{
    if (id != null) 'id': id,
    if (name != null) 'name': name,
    if (isActive != null) 'is_active': isActive,
    if (visits != null) 'visits': visits,
    if (ratio != null) 'ratio': ratio,
    if (startedOn != null) 'started_on': startedOn,
    if (updatedAt != null) 'updated_at': updatedAt,
    if (amount != null) 'amount': amount,
    if (status != null) 'status': status,
    if (secret != null) 'secret': secret,
  };
}