read method

Future<HDict?> read(
  1. String filter, {
  2. bool checked = true,
})
inherited

/////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// Query one entity record that matches the given filter.

If there is more than one record, then it is undefined which one is returned. If there are no matches than return null or raise UnknownRecException based on checked flag.

Implementation

// Read by filter
//////////////////////////////////////////////////////////////////////////

  /// Query one entity record that matches the given filter.
  ///
  /// If there is more than one record, then it is undefined which one is
  /// returned.  If there are no matches than return null or raise
  /// UnknownRecException based on checked flag.
  Future<HDict?> read(String filter, {bool checked = true}) {
    return readAll(filter, limit: 1).then((HGrid grid) {
      if (grid.isNotEmpty) return grid.row(0);

      if (checked) throw UnknownRecError(msg: filter);

      return null;
    });
  }