update method

  1. @override
Future<T> update(
  1. T item
)
override

Updates an existing item in the local database. Returns the updated item.

Implementation

@override
Future<T> update(T item) async {
  final now = DateTime.now();

  final updatedAt = item.updatedAt ?? now;

  final updatedItem = item.copyWith(updatedAt: updatedAt) as T;

  await (database).update(
    tableName,
    updatedItem.toJson(),
    where: 'id = ?',
    whereArgs: [item.id],
    conflictAlgorithm: ConflictAlgorithm.replace,
  );
  return item;
}