save method

  1. @override
Future<E> save(
  1. E entity, {
  2. SaveOptions? options,
  3. TransactionContext? transaction,
})
override

Saves an entity of type E.

Returns the saved entity. Throws a RepositoryException if an error occurs. An optional options parameter can be provided to customize the save behavior.

Implementation

@override
Future<E> save(
  E entity, {
  SaveOptions? options,
  TransactionContext? transaction,
}) async {
  if (transaction != null) {
    throw TransactionException(
      'Transaction is not supported in StorageRepository',
    );
  }

  try {
    await dataSourceHandler.save(entity);
    notifySaveComplete(entity);
    return entity;
  } catch (e) {
    throw EntitySaveException(entity, reason: e.toString());
  }
}