deleteById method

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

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 Thhrows error.

Implementation

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

  var oldItem = await getOneById(correlationId, id);
  var result = await collection?.remove(filter);
  if (result != null && result['ok'] == 1.0) {
    logger.trace(
        correlationId, 'Deleted from %s with id = %s', [collectionName, id]);

    return oldItem;
  }
  return null;
}