deleteById method
Deleted a data item by it's unique id.
correlation_id
(optional) transaction id to trace execution through call chain.id
an id of the item to be deleted Return Future that receives deleted item Throws error.
Implementation
@override
Future<T?> deleteById(String? correlationId, K? id) async {
var index = List.from(items.map((x) {
return x.id;
})).indexOf(id);
if (index < 0) {
logger.trace(correlationId, 'Item %s was not found', [id]);
return null;
}
var item = items[index];
items.removeAt(index);
logger.trace(correlationId, 'Deleted item by %s', [id]);
await save(correlationId);
return item;
}