deleteAndSync method

Future<(bool, DatumSyncResult<T>)> deleteAndSync({
  1. required String id,
  2. required String userId,
  3. DatumSyncOptions<T>? syncOptions,
  4. DeleteBehavior? behavior,
})

Deletes an entity locally and immediately triggers a synchronization.

This is useful for ensuring a delete operation is persisted to the remote server as soon as possible.

The behavior parameter allows overriding the global DatumConfig.deleteBehavior for this specific delete operation. If null, the global config value is used.

Returns a tuple containing a boolean indicating if the local delete was successful and the result of the subsequent synchronization.

Implementation

Future<(bool, DatumSyncResult<T>)> deleteAndSync({
  required String id,
  required String userId,
  DatumSyncOptions<T>? syncOptions,
  DeleteBehavior? behavior,
}) async {
  _ensureInitialized();
  final wasDeleted = await delete(id: id, userId: userId, behavior: behavior);
  final syncResult = await synchronize(userId, options: syncOptions);
  return (wasDeleted, syncResult);
}