deleteById method

  1. @override
Future<T?> deleteById(
  1. String? correlationId,
  2. K? id
)

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 the deleted item.

Implementation

@override
Future<T?> deleteById(String? correlationId, K? id) async {
  var values = {'1': id};

  var query = "DELETE FROM " +
      this.quotedTableName_() +
      " WHERE \"id\"=@1 RETURNING *";

  var res = await client_!.query(query, substitutionValues: values);

  var resValues = res.isNotEmpty
      ? Map<String, dynamic>.fromIterables(
          res.columnDescriptions.map((e) => e.columnName), res.first.toList())
      : null;

  var newItem = this.convertToPublic_(resValues);

  if (newItem != null) {
    logger_.trace(
        correlationId, "Deleted from %s with id = %s", [this.tableName_, id]);
  }

  return newItem;
}