getOneById method
Gets a data item by its unique id.
correlationId
(optional) transaction id to trace execution through call chain.id
an id of data item to be retrieved. Return Future that receives data item or error.
Implementation
@override
Future<T?> getOneById(String? correlationId, K id) async {
var items = List<T>.from(this.items.where((x) {
return x.id == id;
}));
var item = items.isNotEmpty ? items[0] : null;
if (item != null) {
logger.trace(correlationId, 'Retrieved item %s', [id]);
} else {
logger.trace(correlationId, 'Cannot find item by %s', [id]);
}
return item;
}