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 a requested data item or `null if nothing was found.
Implementation
@override
Future<T?> getOneById(String? correlationId, K id) async {
var query = "SELECT * FROM " + this.quotedTableName_() + " WHERE \"id\"=@1";
var params = {'1': id};
var res = await client_!.query(query, substitutionValues: params);
if (res.toList().isEmpty)
this.logger_.trace(correlationId, "Nothing found from %s with id = %s",
[this.tableName_, id]);
else
this.logger_.trace(correlationId, "Retrieved from %s with id = %s",
[this.tableName_, id]);
var resValues = res.isNotEmpty
? Map<String, dynamic>.fromIterables(
res.columnDescriptions.map((e) => e.columnName), res.first.toList())
: null;
var item = this.convertToPublic_(resValues);
return item as T?;
}