readById method

Future<HDict?> readById(
  1. HRef id, {
  2. bool checked = true,
})
inherited

/////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// Calls read to lookup an entity record by it's unique identifier.

If not found then return null or throw an UnknownRecException based on checked.

Implementation

// Read by id
//////////////////////////////////////////////////////////////////////////

  /// Calls [read] to lookup an entity record by it's unique identifier.
  ///
  /// If not found then return null or throw an UnknownRecException based
  /// on checked.
  Future<HDict?> readById(HRef id, {bool checked = true}) {
    return onReadById(id).then((HDict? rec) {
      if (rec != null) return rec;
      if (checked) throw UnknownRecError(id: id);
      return null;
    });
  }