performDeleteWithoutEvents method
Future<bool>
performDeleteWithoutEvents({
- required String id,
- required String userId,
- DataSource source = DataSource.local,
- bool forceRemoteSync = false,
Performs a delete without firing events (used internally for cascading).
Implementation
Future<bool> performDeleteWithoutEvents({
required String id,
required String userId,
DataSource source = DataSource.local,
bool forceRemoteSync = false,
}) async {
final existing = await localAdapter.read(id); // Don't filter by userId for cascade deletes
if (existing == null) {
return false;
}
final deleted = await localAdapter.delete(id, userId: existing.userId); // Use the entity's actual userId
if (!deleted) {
return false;
}
if (source == DataSource.local || forceRemoteSync) {
final operation = _createOperation(
userId: existing.userId, // Use the entity's actual userId
type: DatumOperationType.delete,
entityId: id,
);
// Calculate size for delete operation (it's small, just the ID)
final payload = {'id': id};
final size = (await _isolateHelper.computeJsonEncode(payload)).length;
await _queueManager.enqueue(operation.copyWith(sizeInBytes: size));
}
return true;
}